Deploy a Flask App to Heroku With a Postgres Database

Поделиться
HTML-код
  • Опубликовано: 4 окт 2024

Комментарии • 97

  • @prettyprinted
    @prettyprinted  4 года назад +5

    Join my free course on the basics of Flask-SQLAlchemy: prettyprinted.com/flasksql

  • @kilbeam99
    @kilbeam99 3 года назад +1

    I was stuck on this all day and you helped me fix it in 20 minutes!! I kept trying to get a SQlite database to run on Heroku, but I had no clue that was an impossible task. After following your instructions, Postgres magically sprung to life and my webapp is now even faster than on SQlite! Thank you so much!

  • @Templars69
    @Templars69 3 года назад +1

    Thank you, really good approach on how to setup everything properly. It works perfectly!
    For those who are struggling with the database first initialization and doesn't have a command.py file
    You can simply run from Heroku's console :
    python
    from app_name.py import db
    from models.py import table_name
    db.create_all()
    app_name.py contains db inializiation from SQLAlchemy
    models.py contains your DB Tables (User, Post, Setting)

  • @vladislavkorecky
    @vladislavkorecky 2 года назад +1

    I cant thank you enough. You explain everything in an absolute detail and deploying with you was so easy!

  • @SaifUlIslam-di5xv
    @SaifUlIslam-di5xv 4 года назад +3

    I liked the approach! Debugging things as you go along. Thank you.

  • @davidtso7567
    @davidtso7567 2 года назад

    This video is so lit. The most informatic and detailed one I have ever seen on this topic. Exactly what I want. Thank you so much!!!!!

  • @arctiinae
    @arctiinae 5 лет назад +3

    While I don't use Heroku, it is still instructive to see how things would be done with that service. Thanks! I really liked the step-by-step error handling approach.

    • @prettyprinted
      @prettyprinted  5 лет назад +1

      Yeah, I want people to know the different options out there. I'll make deployment videos for Digital Ocean and Lightsail as well. Thanks for watching!

    • @arctiinae
      @arctiinae 5 лет назад

      @@prettyprinted that's a great list. You might consider Linode too. It's a commonly suggested one from RUclips instructors. I went with that service and really like it (though setting up flask and postgresql was not what I'd call easy!). Cheers,

    • @prettyprinted
      @prettyprinted  5 лет назад +1

      @@arctiinae I'll consider Linode as well. Thanks.

  • @abhinav327
    @abhinav327 4 года назад +1

    Thank you so much for putting these tutorials out. You are an absolute superstar!

  • @radekjestrabik8507
    @radekjestrabik8507 3 года назад

    Thank you so much! This is the first tutorial that was really helpful with deploying more complex Flask application.

  • @joecerniglia9906
    @joecerniglia9906 Год назад

    Thanks for posting this. For a new flask developer, this is groundbreaking. This video really helped me break down barriers to deployment of an app out of a textbook. I still have not been able to deploy the textbook example successfully, but I was able to deploy your app successfully after more than a day of working with it. I rushed the seeding process for the tables and had to go back and do it carefully, step by step, pausing the video a few hundred times and copying everything you did, keystroke by keystroke, but it works, and I'm thrilled. I noticed that you may have forgotten in the video to change the expert field in your auth route to True to allow you to create the user named programming_expert. That, I think, was my real stumbling block. It led me to try to rearrange your model and table relationships, when in fact those were working fine. I had my local version working, so the process of comparing local to Heroku version led me to a process of working on it. The repetition of the work has given me a much stronger background in deployment and mirroring Heroku commands on terminal with the use of the online Heroku app. Again, thank you, Anthony!

  • @somethingwithbryan
    @somethingwithbryan 2 года назад

    wish i saw this two days ago. youre great

  • @ynnkh2116
    @ynnkh2116 5 лет назад +3

    Very very helpful ! Great tutorial! I managed to deploy my app through it.

  • @RhuanLimaTV
    @RhuanLimaTV 4 года назад

    Thanks!!!!!!! Very, very useful! Great tutorial! I am several days trying in to execute this deploy and thanks to your video I got it!

  • @noahdrisort2005
    @noahdrisort2005 4 года назад +2

    Thank you very much, you have save my day
    I was struggling with Postgres on Heroku, I have success (init and migrate on local, upgrade on heroku), but the web cannot connect to database
    The key thing with me is from 15:47 , all another tutorial they don't create the tables, I just need to add line
    "with app.app_context():
    db.create_all()"
    to app.py file then everything on Heroku run automated, amazing
    Some note for who have same problem like me, and for my future set up

    • @elenirazabal3521
      @elenirazabal3521 4 года назад

      This has been so f++`+++ important. Thanks!!!

  • @FilthySnob
    @FilthySnob 3 года назад

    nice video man, I went through the exactly same errors process on my own before watching this videos, and they weren't fun to troubleshoot and fix tbh I wish I found that video earlier!

  • @mikespon
    @mikespon 3 года назад

    Thanks for the information. You're a lifesaver!

  • @antytrend
    @antytrend 5 лет назад +4

    lol, the create tables part is what I came for. I thing building that into the app is good too (if table(s) does not exist create table(s)...)

    • @giv123
      @giv123 4 года назад

      That's a massive pain in the ass!

  • @AmineTeffal
    @AmineTeffal 4 года назад

    Thank you you saved my lifie. The Heroku doc does not say that.

  • @prashanthgk7102
    @prashanthgk7102 4 года назад

    Very helpfull... This video has helped me a lot!! Please create a video on how to host flask web app on firebase.

  • @migueljr6147
    @migueljr6147 4 года назад +2

    How can I access the variable DATABASE_URL in file ".env" locally??? Because when I try use os.environ['DATABASE_URL'] locallly gives Error

    • @fatihsen3002
      @fatihsen3002 4 года назад

      yes ı have error to. Please help us . I have erro like this . sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: posts.

  • @himanshubhatt8565
    @himanshubhatt8565 3 года назад

    Awesome video😎😎

  • @nikosleonardos191
    @nikosleonardos191 3 года назад +1

    what kind of file is the Procfile? My pycharm IDE doesn't automatically pick up the file type like your VScode did.
    Please let me know, thanks!

  • @hasanmsh3380
    @hasanmsh3380 3 года назад

    Thank you

  • @jezjeza1633
    @jezjeza1633 4 года назад +1

    I got psycopg2.errors.UndefinedTable relation user does not exist on heroku. Can anyone help me please ?

    • @lewjunbin7301
      @lewjunbin7301 4 года назад +1

      I faced the same problem. Any solutions?

  • @manolo6048
    @manolo6048 4 года назад

    Thank you very much for the knowledge.
    I am new to web developments, I wanted to find out, is there a limit in terms of storage of the database,
    let's say, I want to create a web app that allows uses to log in and upload media files, how much storage space will heroku give me?

  • @yogeshpandey9549
    @yogeshpandey9549 4 года назад

    I have a Flask application backed by SQLAlchemy database. I just wanted to know if SQLAlchemy databases are supported by Heroku?

  • @calumdavidson2386
    @calumdavidson2386 3 года назад

    Hi great tutorial, am I able to use your code form Github and work backwards from the working version to get it to suit my app? It is a non-profit research task for university and I would be happy to acknowledge you in my research if you please. I've had issues trying to adapt my current code to work and think it would be easier to add my few functions to a working base. Thanks

  • @VincentStevenson
    @VincentStevenson 4 года назад

    Is there another way to create tables from the Heroku console? I am having a hard time running my migrations.py file from Heroku. Thanks!

  • @sto3359
    @sto3359 5 лет назад

    Brilliant guide

  • @purity_one
    @purity_one 3 года назад

    Thank you, man!

  • @angelicaberistain8808
    @angelicaberistain8808 4 года назад

    Thank you!

  • @partumingenii7877
    @partumingenii7877 3 года назад

    Hi, is there a way to update the tables with new fields when it was already created with the command you designed in this video? Thx

  • @pranshuagrawal8046
    @pranshuagrawal8046 4 года назад +2

    I am getting app crashed error. Can you please help me with it

    • @TECNOMUNDOCHANNEL
      @TECNOMUNDOCHANNEL 3 года назад

      I was getting the same error. I fixed it by deleting the requirements.txt file and creating it again.

  • @seannelson9088
    @seannelson9088 3 года назад

    Fantastic

  • @ginacameras1203
    @ginacameras1203 4 года назад

    Is this flask app code available anywhere? Would love to follow along.

  • @sjwang3892
    @sjwang3892 Год назад

    Thanks a lot for your video! What's the best practice if I want to populate the DB when creating it? I have a csv file that needs to be in the db and ready to query (instead of being added by users). Can I do it in the heroku command line?

    • @prettyprinted
      @prettyprinted  Год назад

      Yeah, you can create a script in your repo and then run it with heroku run

    • @sjwang3892
      @sjwang3892 Год назад

      @@prettyprinted Awesome, thanks for you reply

  • @AnishSah_artist
    @AnishSah_artist 5 лет назад

    Hello,
    First of all, very easy to follow tutorial
    However, i am stuck at Deploy Branch. I get an error like this:
    No matching distribution found for python==3.6.8 (from -r /tmp/build_b0affccd122e5514cb1602c0180f741a/requirements.txt (line 1))
    ! Push rejected, failed to compile Python app.
    I updated requirements.txt with python==3.6.9 but still i get the same error with python 3.6.9.
    Any idea why?
    Really looking forward to your response!
    Thanks,
    Anish

  • @yahkeefdavis9265
    @yahkeefdavis9265 5 лет назад

    Question- How do I create the pipe file for an app I've already created? Is it pip freeze > [file_name]? And if so which directory should I be in when I do it?

    • @naumanali8357
      @naumanali8357 4 года назад

      you have to create pipe file to your parent directory like pip freeze > requirements.txt

  • @guptaparas
    @guptaparas 4 года назад

    what if i wanted to read this database? How can I do that ?

  • @אוראלעמדי
    @אוראלעמדי 5 лет назад

    Great Video!

  • @univuniveral9713
    @univuniveral9713 5 лет назад

    Question: Do you know what it means when the name of a class in a django/css template starts with @ ? Example: @media (min-width:768px) {.container{width:750px}}. And also what it means when there are two of them, the second one being @media (min-width:992px){.container{width:970px}}? I am guessing that @media means any media would use the div whose name is "container", overriding the value of its width based on the size mentioned. So how @media is recognised by any video, etc. Are photos included in @media? Please paste an example of media which you have copied from an html file.

    • @abdulazeezatanda2371
      @abdulazeezatanda2371 4 года назад

      In CSS, this is called media query. It's used to adjust app layout to device width or height. Google it.

  • @drustan6890
    @drustan6890 4 года назад +1

    I get an error
    " No default language could be detected for this app.
    HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
    See devcenter.heroku.com/articles/buildpacks"
    What does this mean?

    • @virgobeautygg
      @virgobeautygg 4 года назад

      Did you ever find a resolution for this error? I'm seeking one

    • @ugorjirichard9282
      @ugorjirichard9282 4 года назад

      You need to create a setup.py file in your project directory there should be one you can use in the flask documentation

  • @futurecode602
    @futurecode602 5 лет назад

    Nice tutorial

  • @adriansgailitis
    @adriansgailitis 4 года назад +1

    Is this working right now?

  • @drac8854
    @drac8854 4 года назад

    Error : cannot detech the buildpack to use for this app

  • @2traquinas
    @2traquinas 2 года назад

    Anyone has the tutorial of how he made this website?

  • @caramessina9593
    @caramessina9593 5 лет назад

    THANK YOU!!!

  • @justalone1549
    @justalone1549 3 года назад

    so cool)

  • @maxtan2128
    @maxtan2128 4 года назад

    I'm confused about the whole database thing, my project consists of a .py file and a template folder. Is the database necessary?

    • @prettyprinted
      @prettyprinted  4 года назад +1

      The database file isn't necessary if you're connecting to a database on a server.

  • @G33TarDed
    @G33TarDed 4 года назад

    Hi, Pretty Printed.
    A buddy of mine sent me this video but it doesn't appear to solve my problem.
    I am currently trying to deploy a Flask/SQLite + Alch project to Heroku and I keep getting a run error after a successful build. I read into Heroku docs and it says they don't support SQLite so I'm assuming that's why I'm getting the error.
    I'm trying to find a resource on how to change my SQLAlchemy queries into PostgreSQL for a proper deployment. Can you recommend any resources?
    Thank you!

    • @krishnasivakumar2479
      @krishnasivakumar2479 4 года назад

      Sqlite isn't supported. Just install psycopg2 and run create_all() before starting the app, you don't need to change the queries.

  • @lamaalqasem9069
    @lamaalqasem9069 4 года назад

    can I use their database service for my mobile application?

    • @prettyprinted
      @prettyprinted  4 года назад

      You definitely could. They'll give you a database uri that you could connect to from your app.

  • @jovischuah4031
    @jovischuah4031 4 года назад

    Hi, what if using sql server? is here anyone know how to install odbc driver on heroku?

  • @delllatitude299
    @delllatitude299 5 лет назад

    Awesome tutorial like always Sir

    • @prettyprinted
      @prettyprinted  5 лет назад +1

      I'll think about that as an example. Thanks for the idea.

    • @delllatitude299
      @delllatitude299 5 лет назад

      @@prettyprinted thanks sir

  • @b_sobhan_
    @b_sobhan_ 3 года назад

    I have been developing a chat app with Postgress database in Heroku. But after I got everything on the server side to work and was working on the client side design of webpages, I noticed that I am getting an error from time to time after which the server restarts on its own.
    The error says: sqlalchemy.exc.TimeoutError: QueuePool limit of size 5 overflow 10 reached, connection timed out, timeout 30 (Background on this error at: sqlalche.me/e/13/3o7r)
    Also the connections requests made to the server during this time gets rejected and throws the same error in the browser. I tried searching it on the internet but was not able to get a working solution.
    Some help would be much appreciated.

  • @univuniveral9713
    @univuniveral9713 5 лет назад +1

    Hi. Thanks for the good video. Can we work together to create an app than can forcast? I have the model in python. Let us publish in both Amazon and any of your chosen hosting sites. I supply the model. The model is a python object. Al I need from your part is a web interface where users provide their previous month's figures in an excel sheet, because we need at least 30 historical values. Then they will see their forecast displayed on the website. What do you think?

    • @pial2461
      @pial2461 5 лет назад

      yeah lets do it

    • @univuniveral9713
      @univuniveral9713 5 лет назад

      @@pial2461 So Can we do it step-by-step? First I send you a psuedo model that needs data in excel format, or googlesheets, or an API - whichever way the users find easy to upload their data. Then you do a preliminary quick and ready web interface and send tome for testing. Then we go back and fort iteratively improving it. In the end, both of us will understand the tools. Then I will just replace the old forecasting model with a better one. If it works, then we can suggest different models, or even build a few games.

  • @sobatdigital147
    @sobatdigital147 4 года назад

    .gitignore in .env?

  • @TheApgreyd
    @TheApgreyd 4 года назад +2

    No such command "create_tables"

  • @austinmurphy9074
    @austinmurphy9074 4 года назад

    set up ssh github keys bro

  • @jerrygeorge180
    @jerrygeorge180 2 года назад

    put time stamps

  • @lucasgomez3531
    @lucasgomez3531 4 года назад

    What procfile can i use to deploy the app you did in this video ruclips.net/video/K0vSCCAM2ss/видео.html , since the __init__.py and the procfile would be in the same directory

    • @lucasgomez3531
      @lucasgomez3531 4 года назад

      Solved it! I created a new file application and move all the .py files and templates inside. Then I built the wsgi as u did in this tutorial. Easier than I thought . Thanks :)

  • @SunriseBusinessClub
    @SunriseBusinessClub 4 года назад

    Crazyness.....

  • @chotagunnu7489
    @chotagunnu7489 2 года назад

    Doesn't help at all

  • @vickyvirat5166
    @vickyvirat5166 4 года назад

    Thank you 👍

  • @liubomyr-peteliuk
    @liubomyr-peteliuk 4 года назад

    Thank you, man!

  • @kabylfx
    @kabylfx 4 года назад

    Thank you!