How to build a FastAPI app with PostgreSQL

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

КОМЕНТАРІ • 107

  • @mattmarshall1834
    @mattmarshall1834 9 місяців тому +6

    Great tutorial. Very quick and to the point. It would be interesting to see a video about releasing a FastAPI/React/Postgres application to AWS or GCP.

  • @lotusmojo
    @lotusmojo 8 місяців тому +1

    Great job buddy!.. very clear and concise

  • @ЭрнестОлмасхон
    @ЭрнестОлмасхон 4 місяці тому +2

    thank u man!!! i don't understand all ur words, because my english not good. But this video was better than videos in my native language. I hope that u do more videos about FastAPI, actually FastUI. Thank u so much another time.

  • @pipe3194
    @pipe3194 Рік тому +6

    Great job! 🎉 I really appreciate clears and directs explanations like this one

    • @codingwithroby
      @codingwithroby  Рік тому

      Woot woot! I am so glad you were able to find some value. Cheers!!!

  • @trixer230
    @trixer230 8 місяців тому +1

    I would love this tutorial but showing how to use relationships. For instance how would you make it pull all the answers automagically when the question is pulled?

  • @muhammadnajamulislam2823
    @muhammadnajamulislam2823 10 місяців тому +1

    very nice and easy way of teaching

  • @MaicolArgumedo-m9w
    @MaicolArgumedo-m9w Рік тому +1

    Erck tu ejemplo me ayudo a entender mejor FastApi he visto varios videos y el tuyo es uno de los mejores que los explica, sencillo y al grano, gracias!

  • @onclick-xt3mu
    @onclick-xt3mu 3 місяці тому +1

    Very Great Tutorial, Greetings from Egypt

  • @NobixLee
    @NobixLee 5 місяців тому

    Watching on my phone, can’t wait to follow along I actually need to fully understand this for work. Thanks man

  • @thegreekgoat98
    @thegreekgoat98 Рік тому +7

    It would have been much better if you have explained the logic behind the lines and what it does more clearly especially in database part.

  • @merimagdi
    @merimagdi 2 місяці тому

    Amazing video! I love how you break down complex concepts into simple steps, and the pace is perfect for a beginner like me :) I'm definitely buying your Udemy course. Looking forward to building my next API with FastAPI!

    • @codingwithroby
      @codingwithroby  2 місяці тому

      Woot woot - glad you found it helpful 🙂

  • @cesardavidmillan6648
    @cesardavidmillan6648 Рік тому +1

    It was a great tutorial! even though I made a few changes while watching the tutorial! way to go!

  • @ibrahimshazly9580
    @ibrahimshazly9580 5 місяців тому +1

    Hi, Mr Roby
    on 14:30
    i am wondering why you didn't add
    question = relationship("Question") # Establish relationship
    to choices model
    ---
    and thanks for your tutorial

  • @aviraltiwari3412
    @aviraltiwari3412 Рік тому +2

    Great video. Lot of quality of content. Very informative! I'd suggest creating videos related to CORS, that would be great!

  • @hatem.tommy.lamine
    @hatem.tommy.lamine 11 місяців тому +1

    Great video. Could you share the repo link by any chance please?

    • @codingwithroby
      @codingwithroby  10 місяців тому

      Hey friend, for this video I never saved the repo. Sorry!

  • @rafiali7315
    @rafiali7315 10 місяців тому +1

    i watched your three times but i am got same error my question pass in db perfectly but choices doesnt put,

  • @elykou4843
    @elykou4843 Рік тому

    Mine works now.What a great teacher .thanks you too much.

  • @DIVYANAMBIAR-by7om
    @DIVYANAMBIAR-by7om 7 місяців тому

    Thank you, Eric. Really helpful

  • @АлександрБутин-к9ю
    @АлександрБутин-к9ю 2 місяці тому

    Thank you so much for this video!
    I'm so sorry to ask about it, but how to turn on same auto completion for code which you use in VS code...
    Somehow the VS code offers you everything even at the moment of importing libraries..

    • @codingwithroby
      @codingwithroby  2 місяці тому

      Do you have the python plugin installed? After that I don't have anything fancy going on

  • @yvysunu
    @yvysunu 2 місяці тому

    nice video! do you have one implementing postgres + data validation + docs + auth?

    • @codingwithroby
      @codingwithroby  2 місяці тому +1

      I think scattered around I do - I have a best selling FastAPI course you can take. That will 100% have what you are looking for.

    • @yvysunu
      @yvysunu 2 місяці тому

      @@codingwithroby where do I find it?

    • @codingwithroby
      @codingwithroby  2 місяці тому

      @@yvysunu In the description above for this video under Courses.

  • @domingotrejo4554
    @domingotrejo4554 Рік тому +1

    in a production project the lines of create_all and Annotated go ouside of endpoints, are a good practice ?

    • @codingwithroby
      @codingwithroby  Рік тому

      I would probably use migrations and have a deployment script do it, but for small/medium sized applications, absolutely!

  • @Anteater23
    @Anteater23 5 місяців тому +1

    Great video

  • @hoho-g9n
    @hoho-g9n Рік тому

    Thank you so much! Very detailed explanation!

  • @shotihoch
    @shotihoch 7 місяців тому

    Absolute usefull tutorial. Found it... ughhh finally. Thank you! It was pretty hard to understand db_dependency = Annotated[Session, Depends(get_db)] logic, but with gpt i think I got it. Didnt get about async without await thing.... but I just think it some kind of inner processes of FastAPI requires it. Anyways thank you!

  • @vandanadubey2315
    @vandanadubey2315 Рік тому

    Great Video Eric , Thank you

  • @GayuniBas
    @GayuniBas 23 години тому

    Please when you're making tutorials don't just read the lines. We can read ourselves. We'd appreciate it if you could briefly mention why we need each line.
    But either way, Thank you very much for this tutorial it helped me get a clear overview of how to use FastAPI with PostgreSQL

  • @timothyatanda1188
    @timothyatanda1188 11 місяців тому +1

    Eric, please do you have the completion of this tutorial in your Udemy class with the topic "Fastapi- The Complete Curse 2024 (Beginners+Avanced)? i mean the aspect of the delete, get _by_id and update"🙏

    • @codingwithroby
      @codingwithroby  11 місяців тому

      It is not exactly this tutorial, but it shows how to do almost everything 🙂

    • @codingwithroby
      @codingwithroby  11 місяців тому

      I am confident it will have what you are looking for

  • @seemahebbar7002
    @seemahebbar7002 26 днів тому

    This is a really great video, however I'm getting winerror 10013 an attempt was made to access a socket in a way forbidden by its access permissions error. Kindly help and let me know where I went wrong

  • @dipanjansaha6824
    @dipanjansaha6824 Рік тому +1

    Coming from MVC background! How about we put the files into a production grade folder 📂 structure?

    • @codingwithroby
      @codingwithroby  Рік тому

      The idea here was to simply show how to setup FastAPI with PostgreSQL. I appreciate your feedback🙂

    • @metinEsturb
      @metinEsturb Рік тому

      @dipanjansaha6824: how would this structure that you mention look like? Do you have any reconmendations?

  • @fahdagodzo5795
    @fahdagodzo5795 8 місяців тому +1

    thanks, it's been helpful

  • @AxlRoseGVillanueva
    @AxlRoseGVillanueva 8 місяців тому

    Greate tutorial!! how can we update database if we made changes from models? I really appreciate!

    • @codingwithroby
      @codingwithroby  7 місяців тому

      You will want to use something like Alembic. If it is a brand new app, you can delete the db and let SQLAlchemy recreate a new one for you.

  • @tihomirkamenov2862
    @tihomirkamenov2862 Рік тому

    Awesome video!
    p.s. An async function without an await expression will run synchronously :)

    • @codingwithroby
      @codingwithroby  Рік тому

      Nice addition!

    • @AzharRafiq
      @AzharRafiq 10 місяців тому

      when we should use async vs def only?

    • @tihomirkamenov2862
      @tihomirkamenov2862 10 місяців тому

      Typically, async returns another async def most of the time (with await) until it reaches the final stage - any data from database, message, string, int etc. On the last stage the def should be also async but it will return with no await
      So in this case, @codingwithroby is correct, my mistake! @@AzharRafiq
      However, we use async def to avoid big delays when fetching data. This allows the program to switch between multiple tasks without blocking the main thread.

  • @ledieuduballonrond456
    @ledieuduballonrond456 9 місяців тому

    Hi Eric I hope you're doing well,
    I have a slight issue when I paste the URL on my browser i keep getting "detail" : "not found". If anyone could help me please ?

    • @mattmarshall1834
      @mattmarshall1834 9 місяців тому

      What is the url that you are pasting? If you past the localhost url without anything after it the "detail":"not found" message will appear.

    • @ledieuduballonrond456
      @ledieuduballonrond456 9 місяців тому

      So what should I paste ?

  • @mrkzmusic
    @mrkzmusic Рік тому

    Thanks a lot Eric!

  • @raulmedrano9818
    @raulmedrano9818 Рік тому +1

    thanks excellent job

  • @iVentusHD
    @iVentusHD Рік тому

    HELLO PLEASE, i need you're help i followed the tuto exactly but when i want to launch the API i have an error "from sqlalchemy import Session
    ImportError: cannot import name 'Session' from 'sqlalchemy'"

    • @codingwithroby
      @codingwithroby  Рік тому

      Hey friend! How is it going? Let's figure out what is going on here. When are you doing this? It should be session maker if you are adding: from sqlalchemy.orm import sessionmaker

    • @iVentusHD
      @iVentusHD Рік тому

      @@codingwithroby hey, the ImportError is Gone but when i do the Post endpoint they add null data to the database (i try to make my own api with user and when i post an user i can see the ID in database but all of the other data is null)

    • @codingwithroby
      @codingwithroby  Рік тому

      @@iVentusHD What does your Python method look like?

  • @goswami_himanshu
    @goswami_himanshu Рік тому +1

    Great tutorial Eric.
    If you can create a video on slightly complex project using fastAPI and postgreSQL i'll watch it even if it's 3 hours long
    Btw you don't have to import List from typing anymore. New versions of python provides this already with the name list

    • @codingwithroby
      @codingwithroby  Рік тому +1

      Thanks for the suggestion! What exactly are you wanting to see so I have a better understanding 🙂

    • @parnika2277
      @parnika2277 Рік тому +1

      @@codingwithroby maybe a program that has 2 tables one for student info and one for student marks and then you calculate things like average, grade, etc

  • @VeejayRampay
    @VeejayRampay 8 місяців тому

    class with a plural name are bad form but this is a nice video, props

  • @timothyatanda1188
    @timothyatanda1188 Рік тому

    What a comprehensive tutorial video, that was amazing!
    please do you have a class on Udemy where i can learn from you very well?

  • @juandelgado6201
    @juandelgado6201 9 місяців тому

    Can you share github repo with that project ?

  • @fatti.casuali
    @fatti.casuali Рік тому +1

    Hi! Can anyone help me? I would like to have a GET endpoint that returns a JSON like this:
    {
    "question_text": "question",
    "choices": [
    {
    "choice_text": "answer1",
    "is_correct": true
    },
    {
    "choice_text": "answer2",
    "is_correct": false
    },
    {
    "choice_text": "answer3",
    "is_correct": false
    },
    {
    "choice_text": "answer4",
    "is_correct": false
    }
    ]
    }
    How do I do it? It seems like I can't select the columns I want even if the query seems right:
    print(select(Questions, Choices).where(Questions.id == Choices.question_id))
    SELECT questions.id, questions.question_text, choices.id AS id_1, choices.choice_text, choices.is_correct, choices.question_id
    FROM questions, choices
    WHERE questions.id = choices.question_id
    Thanks for the help!

    • @codingwithroby
      @codingwithroby  Рік тому

      If you want this all in a single JSON, I would suggest creating another Python object that holds a String along with the choices objects, query the DB and place the info accordingly with the object you are returning.

    • @elykou4843
      @elykou4843 Рік тому

      Post IS where you creat every thing'Just past it in thé post Doc and get it in thé get questions.

  • @owaisahmed2063
    @owaisahmed2063 6 місяців тому

    pgadmin video link please

  • @notalanjoseph
    @notalanjoseph Рік тому

    How to host this on render?

    • @codingwithroby
      @codingwithroby  Рік тому

      Render is one option and another option is AWS. I have a video on AWS deployment you may be interested in.

  • @sebastianmonroy5553
    @sebastianmonroy5553 2 місяці тому

    i need your help

  • @snir109
    @snir109 Рік тому

    Thank you

  • @AnindyaMitra-c5u
    @AnindyaMitra-c5u 17 днів тому

    I am watching the video midway through...not sure why application programmers are hell-bent on managing data model in programming languages. There are data modelling tools for that. Like I can write every logic in DB stored procedures than Python but that would be a bad solution design. What I would expect from an ORM is to give a semantic layer to define object structure and also option to map object data components with DB tables and columns. So my semantic layer that is used in coding is not impacted even if DB side undergoes changes. Example, my Python name "Questions.id" may be mapped to "T_Question.skey" table+column in DB. ER modelling do not use plural names for tables as it refers to each tuple instance by the name as a set. Where can I do that in this ORM? For me, an ORM is a design platform not programming. But did not get that clarity from the demo. May be I need to check the documentation if such options are there. An ORM with UML/ER modelling like GUI interface where we can simply drag and drop from DB catalog/metadata would be preferred. Also should be able to give impact analysis when DB model is altered.

  • @akashsoni7925
    @akashsoni7925 11 місяців тому

    Create something like this
    1) user registration in FastAPI ( Using two database PostgreSQL and MongoDB )
    Registration fields - Full Name,Email,Password,Phone,Profile_picture
    First Name,Password,Email,Phone - postgreSQL
    Profile picture - MongoDB
    Check Email already exist
    2) user registration in fastAPI ( Using postgreSQL )
    Registration fields - Full Name,Email,Password,Phone,Profile_picture
    Create table Users to store : First Name,Password,Email,Phone
    Create table Profile to store : Profile_picture
    Check Email , Phone already exist

  • @kp12345-n
    @kp12345-n 10 днів тому

    I'm disappointed. Users could learn more from the ChatGPT than watching this video. You didn't show Async SQLAlchemy which is a challenging topic. Sync SQLAlchemy is pretty straightforward.

    • @codingwithroby
      @codingwithroby  9 днів тому

      Thanks for the feedback

    • @paulsilas6295
      @paulsilas6295 4 дні тому

      Hey you can find other resources that teaches Async SQLAlchemy, or use the same acclaimed chatGPT to learn async SQLAlchemy so you would never be disappointed in life again.

    • @kp12345-n
      @kp12345-n 3 дні тому

      @@paulsilas6295 Of course I can refer to different resources but I was expecting a better output from Eric.

  • @nehagawande1377
    @nehagawande1377 Рік тому +1

    can you share code

    • @codingwithroby
      @codingwithroby  Рік тому +2

      I do not have this code specifically anymore, but I can definitely look into keeping all code from my UA-cams.