Deploy a Flask App to Heroku With a Postgres Database

Поділитися
Вставка
  • Опубліковано 20 гру 2024

КОМЕНТАРІ •

  • @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!

  • @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!!!!!

  • @joecerniglia9906
    @joecerniglia9906 2 роки тому

    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!

  • @vladislavkorecky
    @vladislavkorecky 2 роки тому +1

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

  • @Templars69
    @Templars69 4 роки тому +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)

  • @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 UA-cam 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.

  • @SaifUlIslam-di5xv
    @SaifUlIslam-di5xv 4 роки тому +3

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

  • @somethingwithbryan
    @somethingwithbryan 2 роки тому

    wish i saw this two days ago. youre great

  • @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

  • @ynnkh2116
    @ynnkh2116 5 років тому +3

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

  • @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.

  • @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

  • @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

  • @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!

  • @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!

  • @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!

  • @calumdavidson2386
    @calumdavidson2386 4 роки тому

    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

  • @adriansgailitis
    @adriansgailitis 4 роки тому +1

    Is this working right now?

  • @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?

  • @guptaparas
    @guptaparas 4 роки тому

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

  • @FilthySnob
    @FilthySnob 4 роки тому

    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!

  • @AmineTeffal
    @AmineTeffal 4 роки тому

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

  • @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?

  • @ginacameras1203
    @ginacameras1203 4 роки тому

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

  • @yogeshpandey9549
    @yogeshpandey9549 4 роки тому

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

  • @pranshuagrawal8046
    @pranshuagrawal8046 4 роки тому +2

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

    • @TECNOMUNDOCHANNEL
      @TECNOMUNDOCHANNEL 4 роки тому

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

  • @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!

  • @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.

  • @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

  • @mikespon
    @mikespon 3 роки тому

    Thanks for the information. You're a lifesaver!

  • @2traquinas
    @2traquinas 2 роки тому

    Anyone has the tutorial of how he made this website?

  • @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 5 років тому

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

  • @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 5 років тому

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

  • @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

  • @himanshubhatt8565
    @himanshubhatt8565 3 роки тому

    Awesome video😎😎

  • @maxtan2128
    @maxtan2128 5 років тому

    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  5 років тому +1

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

  • @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.

  • @b_sobhan_
    @b_sobhan_ 4 роки тому

    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.

  • @drac8854
    @drac8854 4 роки тому

    Error : cannot detech the buildpack to use for this app

  • @jovischuah4031
    @jovischuah4031 5 років тому

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

  • @TheApgreyd
    @TheApgreyd 4 роки тому +2

    No such command "create_tables"

  • @sobatdigital147
    @sobatdigital147 5 років тому

    .gitignore in .env?

  • @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.

  • @sto3359
    @sto3359 5 років тому

    Brilliant guide

  • @אוראלעמדי
    @אוראלעמדי 5 років тому

    Great Video!

  • @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

  • @futurecode602
    @futurecode602 5 років тому

    Nice tutorial

  • @liubomyr-peteliuk
    @liubomyr-peteliuk 5 років тому

    Thank you, man!

  • @lucasgomez3531
    @lucasgomez3531 4 роки тому

    What procfile can i use to deploy the app you did in this video ua-cam.com/video/K0vSCCAM2ss/v-deo.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 :)

  • @hasanmsh3380
    @hasanmsh3380 3 роки тому

    Thank you

  • @seannelson9088
    @seannelson9088 4 роки тому

    Fantastic

  • @kabylfx
    @kabylfx 4 роки тому

    Thank you!

  • @austinmurphy9074
    @austinmurphy9074 4 роки тому

    set up ssh github keys bro

  • @justalone1549
    @justalone1549 3 роки тому

    so cool)

  • @jerrygeorge180
    @jerrygeorge180 2 роки тому

    put time stamps

  • @caramessina9593
    @caramessina9593 5 років тому

    THANK YOU!!!

  • @SunriseBusinessClub
    @SunriseBusinessClub 4 роки тому

    Crazyness.....

  • @chotagunnu7489
    @chotagunnu7489 2 роки тому

    Doesn't help at all

  • @purity_one
    @purity_one 4 роки тому

    Thank you, man!

  • @vickyvirat5166
    @vickyvirat5166 4 роки тому

    Thank you 👍

  • @angelicaberistain8808
    @angelicaberistain8808 4 роки тому

    Thank you!