How to build a FastAPI app with PostgreSQL

In this FastAPI PostgreSQL + pgAdmin video, we'll delve into FastAPI, a powerful python web framework and SQLAlchemy, a SQL toolkit that enhances the flexibility of SQL. You'll learn how these two integrate, creating a potent duo for web development with a professional PostgreSQL database.
Our guide includes a quick overview of PostgreSQL and pgAdmin, an open-source database system and its web-based administration tool, ensuring top-notch database management.
Finally, we'll cover Pydantic for data validation and parsing, a vital component for any robust FastAPI application working with PostgreSQL.
By the end of this video, you'll have the knowledge to build a FastAPI application, utilizing SQLAlchemy, PostgreSQL, pgAdmin, and Pydantic.
🎥 React + FastAPI: • How to build a React +...
🎥 AWS Lambda + FastAPI: • Deploy FastAPI on AWS ...
🎥 MongoDB + FastAPI: • Unlocking the Power of...
🎥 MySQL + FastAPI: • How to build a FastAPI...
===========================
🎓 Courses can be found:
FastAPI Beginner & Advanced: www.udemy.com/course/fastapi-...
Learn Chatbot Development: www.udemy.com/course/the-comp...
===========================
🛒 GEAR & RECOMMENDED BOOKS: kit.co/codingwithroby
⌚️Timestamps:
0:00 Introduction
01:00 FastAPI, SQLAlchemy, uvicorn, pydantic installation
03:00 Start FastAPI Application
07:00 Create PostgreSQL connection
07:45 pgAdmin GUI
11:00 Create PostgreSQL Tables
16:00 Connect FastAPI, PostgreSQL with SQLAlchemy
17:00 FastAPI API Endpoints
Happy coding!
#codingwithroby #fastapi #postgresql

Пікірлер: 75

  • @user-gv4tt6sm7r
    @user-gv4tt6sm7r7 ай бұрын

    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!

  • @user-uf3xl5un3p
    @user-uf3xl5un3p5 ай бұрын

    Thank you so much! Very detailed explanation!

  • @codingwithroby

    @codingwithroby

    5 ай бұрын

    Glad it was helpful! 🙂

  • @pipe3194
    @pipe31948 ай бұрын

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

  • @codingwithroby

    @codingwithroby

    8 ай бұрын

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

  • @lotusmojo
    @lotusmojo2 ай бұрын

    Great job buddy!.. very clear and concise

  • @codingwithroby

    @codingwithroby

    Ай бұрын

    Glad you liked it! 🙂

  • @aviraltiwari3412
    @aviraltiwari341211 ай бұрын

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

  • @codingwithroby

    @codingwithroby

    11 ай бұрын

    Great suggestion!

  • @elykou4843
    @elykou48438 ай бұрын

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

  • @codingwithroby

    @codingwithroby

    8 ай бұрын

    Thank you so much 🙂

  • @DIVYANAMBIAR-by7om
    @DIVYANAMBIAR-by7om23 күн бұрын

    Thank you, Eric. Really helpful

  • @codingwithroby

    @codingwithroby

    23 күн бұрын

    Glad it was helpful!

  • @mattmarshall1834
    @mattmarshall18342 ай бұрын

    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.

  • @codingwithroby

    @codingwithroby

    2 ай бұрын

    Thanks friend !

  • @vandanadubey2315
    @vandanadubey23156 ай бұрын

    Great Video Eric , Thank you

  • @codingwithroby

    @codingwithroby

    6 ай бұрын

    Glad it was helpful! 🙂

  • @cesardavidmillan6648
    @cesardavidmillan66487 ай бұрын

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

  • @codingwithroby

    @codingwithroby

    7 ай бұрын

    Great to hear! Woot woot 🙂

  • @mrkzmusic
    @mrkzmusic6 ай бұрын

    Thanks a lot Eric!

  • @codingwithroby

    @codingwithroby

    6 ай бұрын

    You are more than welcome!

  • @muhammadnajamulislam2823
    @muhammadnajamulislam28234 ай бұрын

    very nice and easy way of teaching

  • @codingwithroby

    @codingwithroby

    4 ай бұрын

    Thanks, friend!

  • @shotihoch
    @shotihochАй бұрын

    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

    Ай бұрын

    Great to hear! Thank you! 😊

  • @fahdagodzo5795
    @fahdagodzo5795Ай бұрын

    thanks, it's been helpful

  • @codingwithroby

    @codingwithroby

    Ай бұрын

    You're welcome! 🙂

  • @trixer230
    @trixer230Ай бұрын

    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?

  • @rafiali7315
    @rafiali73154 ай бұрын

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

  • @goswami_himanshu
    @goswami_himanshu8 ай бұрын

    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

    8 ай бұрын

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

  • @parnika2277

    @parnika2277

    8 ай бұрын

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

  • @domingotrejo4554
    @domingotrejo45547 ай бұрын

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

  • @codingwithroby

    @codingwithroby

    7 ай бұрын

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

  • @raulmedrano9818
    @raulmedrano98187 ай бұрын

    thanks excellent job

  • @codingwithroby

    @codingwithroby

    7 ай бұрын

    Glad you were able to find value 🙂

  • @tihomirkamenov2862
    @tihomirkamenov28625 ай бұрын

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

  • @codingwithroby

    @codingwithroby

    5 ай бұрын

    Nice addition!

  • @AzharRafiq

    @AzharRafiq

    4 ай бұрын

    when we should use async vs def only?

  • @tihomirkamenov2862

    @tihomirkamenov2862

    4 ай бұрын

    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.

  • @TommyPiano.
    @TommyPiano.4 ай бұрын

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

  • @codingwithroby

    @codingwithroby

    4 ай бұрын

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

  • @dipanjansaha6824
    @dipanjansaha68249 ай бұрын

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

  • @codingwithroby

    @codingwithroby

    9 ай бұрын

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

  • @metinEsturb

    @metinEsturb

    6 ай бұрын

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

  • @snir109
    @snir10910 ай бұрын

    Thank you

  • @codingwithroby

    @codingwithroby

    10 ай бұрын

    You are welcome 🙂

  • @AxlRoseGVillanueva
    @AxlRoseGVillanuevaАй бұрын

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

  • @codingwithroby

    @codingwithroby

    Ай бұрын

    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.

  • @ledieuduballonrond456
    @ledieuduballonrond4563 ай бұрын

    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

    2 ай бұрын

    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

    2 ай бұрын

    So what should I paste ?

  • @timothyatanda1188
    @timothyatanda11885 ай бұрын

    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

    5 ай бұрын

    Yes I do! Link is in description 🙂

  • @timothyatanda1188
    @timothyatanda11884 ай бұрын

    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

    4 ай бұрын

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

  • @codingwithroby

    @codingwithroby

    4 ай бұрын

    I am confident it will have what you are looking for

  • @iVentusHD
    @iVentusHD9 ай бұрын

    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

    9 ай бұрын

    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

    9 ай бұрын

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

    9 ай бұрын

    @@iVentusHD What does your Python method look like?

  • @thegreekgoat98
    @thegreekgoat9811 ай бұрын

    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

    11 ай бұрын

    Thanks for your recommendations!

  • @juandelgado6201
    @juandelgado62013 ай бұрын

    Can you share github repo with that project ?

  • @VeejayRampay
    @VeejayRampay2 ай бұрын

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

  • @fatti.casuali
    @fatti.casuali8 ай бұрын

    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

    8 ай бұрын

    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

    8 ай бұрын

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

  • @notalanjoseph
    @notalanjoseph6 ай бұрын

    How to host this on render?

  • @codingwithroby

    @codingwithroby

    6 ай бұрын

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

  • @akashsoni7925
    @akashsoni79255 ай бұрын

    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

  • @nehagawande1377
    @nehagawande13779 ай бұрын

    can you share code

  • @codingwithroby

    @codingwithroby

    9 ай бұрын

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

Келесі