How to build a FastAPI app with PostgreSQL

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ม.ค. 2025

ความคิดเห็น • 111

  • @mattmarshall1834
    @mattmarshall1834 10 หลายเดือนก่อน +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.

  • @ЭрнестОлмасхон
    @ЭрнестОлмасхон 5 หลายเดือนก่อน +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.

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

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

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว +1

      Thanks for your recommendations!

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

  • @lotusmojo
    @lotusmojo 9 หลายเดือนก่อน +1

    Great job buddy!.. very clear and concise

    • @codingwithroby
      @codingwithroby  9 หลายเดือนก่อน

      Glad you liked it! 🙂

  • @trixer230
    @trixer230 9 หลายเดือนก่อน +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?

  • @merimagdi
    @merimagdi 3 หลายเดือนก่อน

    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  3 หลายเดือนก่อน

      Woot woot - glad you found it helpful 🙂

  • @pushkarbansal1926
    @pushkarbansal1926 5 วันที่ผ่านมา

    Great, to the point video, and love the bg music

  • @NobixLee
    @NobixLee 6 หลายเดือนก่อน

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

    • @codingwithroby
      @codingwithroby  6 หลายเดือนก่อน

      Glad it was helpful!

  • @ibrahimshazly9580
    @ibrahimshazly9580 6 หลายเดือนก่อน +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

  • @hatem.tommy.lamine
    @hatem.tommy.lamine ปีที่แล้ว +1

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

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว

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

  • @aviraltiwari3412
    @aviraltiwari3412 ปีที่แล้ว +2

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

  • @onclick-xt3mu
    @onclick-xt3mu 4 หลายเดือนก่อน +1

    Very Great Tutorial, Greetings from Egypt

    • @codingwithroby
      @codingwithroby  4 หลายเดือนก่อน

      Thanks for watching! Cheers 🙂

  • @mimiomare9439
    @mimiomare9439 24 วันที่ผ่านมา

    This was really helpful; thank you!

  • @muhammadnajamulislam2823
    @muhammadnajamulislam2823 11 หลายเดือนก่อน +1

    very nice and easy way of teaching

  • @cesardavidmillan6648
    @cesardavidmillan6648 ปีที่แล้ว +1

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

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

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

  • @rafiali7315
    @rafiali7315 11 หลายเดือนก่อน +1

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

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

  • @yvysunu
    @yvysunu 3 หลายเดือนก่อน

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

    • @codingwithroby
      @codingwithroby  3 หลายเดือนก่อน +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 3 หลายเดือนก่อน

      @@codingwithroby where do I find it?

    • @codingwithroby
      @codingwithroby  3 หลายเดือนก่อน

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

  • @timothyatanda1188
    @timothyatanda1188 ปีที่แล้ว +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  ปีที่แล้ว

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

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว

      I am confident it will have what you are looking for

  • @АлександрБутин-к9ю
    @АлександрБутин-к9ю 3 หลายเดือนก่อน

    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  3 หลายเดือนก่อน

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

  • @elykou4843
    @elykou4843 ปีที่แล้ว

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

  • @DIVYANAMBIAR-by7om
    @DIVYANAMBIAR-by7om 8 หลายเดือนก่อน

    Thank you, Eric. Really helpful

    • @codingwithroby
      @codingwithroby  8 หลายเดือนก่อน

      Glad it was helpful!

  • @hoho-g9n
    @hoho-g9n ปีที่แล้ว

    Thank you so much! Very detailed explanation!

  • @shotihoch
    @shotihoch 8 หลายเดือนก่อน

    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!

    • @codingwithroby
      @codingwithroby  8 หลายเดือนก่อน +1

      Great to hear! Thank you! 😊

  • @vandanadubey2315
    @vandanadubey2315 ปีที่แล้ว

    Great Video Eric , Thank you

  • @AxlRoseGVillanueva
    @AxlRoseGVillanueva 9 หลายเดือนก่อน

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

    • @codingwithroby
      @codingwithroby  8 หลายเดือนก่อน

      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.

  • @Anteater23
    @Anteater23 6 หลายเดือนก่อน +1

    Great video

  • @seemahebbar7002
    @seemahebbar7002 หลายเดือนก่อน

    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

  • @ledieuduballonrond456
    @ledieuduballonrond456 11 หลายเดือนก่อน

    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 10 หลายเดือนก่อน

      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 10 หลายเดือนก่อน

      So what should I paste ?

  • @fahdagodzo5795
    @fahdagodzo5795 9 หลายเดือนก่อน +1

    thanks, it's been helpful

    • @codingwithroby
      @codingwithroby  9 หลายเดือนก่อน

      You're welcome! 🙂

  • @juandelgado6201
    @juandelgado6201 10 หลายเดือนก่อน

    Can you share github repo with that project ?

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

  • @mrkzmusic
    @mrkzmusic ปีที่แล้ว

    Thanks a lot Eric!

  • @tihomirkamenov2862
    @tihomirkamenov2862 ปีที่แล้ว

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

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว

      Nice addition!

    • @AzharRafiq
      @AzharRafiq 11 หลายเดือนก่อน

      when we should use async vs def only?

    • @tihomirkamenov2862
      @tihomirkamenov2862 11 หลายเดือนก่อน

      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.

  • @GayuniBas
    @GayuniBas หลายเดือนก่อน

    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

    • @codingwithroby
      @codingwithroby  หลายเดือนก่อน

      Thanks for the feedback, cheers!

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

  • @owaisahmed2063
    @owaisahmed2063 7 หลายเดือนก่อน

    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.

  • @AnindyaMitra-c5u
    @AnindyaMitra-c5u หลายเดือนก่อน

    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.

  • @VeejayRampay
    @VeejayRampay 9 หลายเดือนก่อน

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

  • @raulmedrano9818
    @raulmedrano9818 ปีที่แล้ว +1

    thanks excellent job

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว

      Glad you were able to find value 🙂

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

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว

      Yes I do! Link is in description 🙂

  • @sebastianmonroy5553
    @sebastianmonroy5553 3 หลายเดือนก่อน

    i need your help

  • @akashsoni7925
    @akashsoni7925 ปีที่แล้ว

    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

  • @snir109
    @snir109 ปีที่แล้ว

    Thank you

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

  • @kp12345-n
    @kp12345-n หลายเดือนก่อน +1

    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  หลายเดือนก่อน

      Thanks for the feedback

    • @paulsilas6295
      @paulsilas6295 หลายเดือนก่อน +2

      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 หลายเดือนก่อน

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