Тёмный

Python FastAPI Tutorial: How to Connect FastAPI to Database 

Eric Roby
Подписаться 9 тыс.
Просмотров 39 тыс.
50% 1

Опубликовано:

 

14 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 62   
@boy291-z8c
@boy291-z8c Год назад
clear and concise!! I love it. Good job sir!
@codingwithroby
@codingwithroby Год назад
Glad you enjoyed it! Good luck within your FastAPI journey :-)
@spider279
@spider279 2 года назад
most Beautiful and comprehensible video on FASTAPI with database , thanks man +1 follower
@codingwithroby
@codingwithroby Год назад
You're awesome! Thanks :-)
@debhasish
@debhasish Год назад
Very very clear instructions and explanations. Thank you for making this video. :)
@codingwithroby
@codingwithroby Год назад
I am glad you enjoyed it! 😊
@anujonthemove
@anujonthemove Год назад
Got to learn a lot of things through this video!
@codingwithroby
@codingwithroby 11 месяцев назад
Awesome! Glad you are here!
@SaraLeaGorenshtein
@SaraLeaGorenshtein Год назад
love it! very clear and easy to understand
@codingwithroby
@codingwithroby Год назад
I am glad you enjoyed it :-)
@alielshimy9028
@alielshimy9028 Год назад
If im working with an already existing database will the same concept work?
@codingwithroby
@codingwithroby Год назад
It will 🙂
@aviraltiwari3412
@aviraltiwari3412 Год назад
Subbed! Create more FastAPI content man, know your audience.
@codingwithroby
@codingwithroby Год назад
Thanks for the kind words! You’re the best. Is there anything you want to see in a future video regarding FastAPI?
@aviraltiwari3412
@aviraltiwari3412 Год назад
@@codingwithroby Yep, a whole series would be great, your way of teaching is really good. Topics like authentication, background tasks etc. would be nice really.
@bertlemoi431
@bertlemoi431 Год назад
everything i learned yesterday by looking at code in 10mins. i should have checked youtube yesterday...
@codingwithroby
@codingwithroby Год назад
Thank you! I am glad you are here :-)
@marcodigennarobari
@marcodigennarobari Год назад
nice work! simple and useful how about a third video showing how to mock the data in the sql db for testing purposes?
@codingwithroby
@codingwithroby Год назад
Not a bad idea!
@vinni_codes
@vinni_codes 2 года назад
I love the video, super useful. Thanks for sharing.
@codingwithroby
@codingwithroby 2 года назад
Glad you found it useful :) thanks for watching
@pleabargain
@pleabargain 2 года назад
Any chance you will continue and add a video on how to get web templates to interact with your book db? Thank you!
@codingwithroby
@codingwithroby Год назад
Hey friend, check out my full course on the subject :-) www.udemy.com/course/fastapi-the-complete-course/
@nicolasaltamirano5572
@nicolasaltamirano5572 2 года назад
Great work man, it help me a lot! Keep it going \,,/
@codingwithroby
@codingwithroby Год назад
Thanks friend!
@spider279
@spider279 2 года назад
Question ? can we create for other get,post,put and delete method for another BaseModel class ? with the same database
@spider279
@spider279 2 года назад
hello please
@codingwithroby
@codingwithroby Год назад
You can, but it would be better to keep the validation separate from the database models
@pietraderdetective8953
@pietraderdetective8953 Год назад
Great video! Can you make a video for Quart (another async framework for Python) ? It's the async version of Flask but recently able to use Flask extensions..which makes it potentially as popular as Flask itself. Liked and subscribed!
@codingwithroby
@codingwithroby Год назад
Hmm interesting, I will take a look at the Quart framework. Is this something you use often?
@pietraderdetective8953
@pietraderdetective8953 Год назад
​@@codingwithroby I have been using Flask for some time, has been contemplating to migrate to Quart due to its native async capabilities...but hesitated due to very limited extension ecosystem compared to Flask. But a couple of months back there's a new development: a library called quart-flask-patch (written by the author of Quart himself) which enables a lot of the most important Flask extensions to be used in Quart. ~ so essentially what "crippled" Quart's potential has disappeared.. I deployed a test page of Quart last week and the async works so good I don't think I would ever go back to a synchronous framework.
@andreww406
@andreww406 Год назад
Hi, after create a new book, I want to take the ID of that inserted raw, how should I do?
@codingwithroby
@codingwithroby Год назад
Try something similar to: f = Foo(bar=x) session.add(f) session.flush() # At this point, the object f has been pushed to the DB, # and has been automatically assigned a unique primary key id f.id # is None session.refresh(f) # refresh updates given object in the session with its state in the DB # (and can also only refresh certain attributes - search for documentation) f.id # is the automatically assigned primary key ID given in the database.
@clearthinking5441
@clearthinking5441 Год назад
is there a way of doing this with a context manager?
@codingwithroby
@codingwithroby Год назад
Which part are you referring to? Like the opening and closing of the database connection?
@rcdag-b5z
@rcdag-b5z Год назад
that was what I exactly needed. Thank you so much!
@codingwithroby
@codingwithroby Год назад
You're so welcome!
@chriskeo392
@chriskeo392 2 года назад
LFG! SQLModel advanced queries up next???!?!?
@codingwithroby
@codingwithroby 2 года назад
I’m starting a new series currently on passing coding interview questions. I have multiple videos lining up! First one will be released this week :)
@Lupo9
@Lupo9 Год назад
It seems unintuitive to me that I would have to manage the SQLAlchemy model and also the pydantic model.
@codingwithroby
@codingwithroby Год назад
Pydantic model is for the request coming in. It will do data validation. SQLAlchemy model is for the actual record in the database. Not all requests will match the model in the database exactly the same - in small applications like this sure, but it is best to have them separated 🙂
@Lupo9
@Lupo9 Год назад
@@codingwithroby Thanks :) I just skimmed the fastapi docs on relational DBs and found out about ORM mode. Also the seperation of concerns clicked for me when I compared it to a Django model with a DRF serializer.
@dosengthavong8854
@dosengthavong8854 2 года назад
I had a problem with creating a sqlite db. So, after I created the books.db file it only has id column creating inside, no title, author ... column created. I tried deleted the .db file also the __pycache__.py, then re-run the program but still did work
@spider279
@spider279 2 года назад
do you have solution now
@dosengthavong8854
@dosengthavong8854 2 года назад
@@spider279 Actually, I made a silly mistake lol. So in models.py instead of ... title = Column(String) ... I wrote ... title : Column(String) ... also in all other fields. This is why there are no fields created in books.db, except ID field
@codingwithroby
@codingwithroby Год назад
Glad you were able to figure it out :-)
@armaanthadani9709
@armaanthadani9709 6 месяцев назад
HI, I use postgresql and this is URL format I used - "postgresql://user:password@host:port/database_name" is that correct?
@aadargupta
@aadargupta 4 месяца назад
I get models is not a module, even though it is in the same directory
@divyanambiar5009
@divyanambiar5009 5 месяцев назад
How to implement level 3 Rest with fast API ?
@codingwithroby
@codingwithroby 5 месяцев назад
I am not familiar with the term "level 3 Rest" - what is that?
@elmouatamidbenatia8754
@elmouatamidbenatia8754 Год назад
great job
@codingwithroby
@codingwithroby Год назад
Thanks a bunch!
@daniilpogolovkin8221
@daniilpogolovkin8221 Год назад
Tnx!
@codingwithroby
@codingwithroby Год назад
Thank you!
@robinmaurer2645
@robinmaurer2645 2 года назад
the autoincrement doesnt work for me ... any tipps?
@paagosamuel6716
@paagosamuel6716 Год назад
Thank you, I ll love to see it with mongodb
@codingwithroby
@codingwithroby Год назад
Ohhh, great idea.
@yolowex6876
@yolowex6876 2 месяца назад
You could explain all that in 10 minutes
@codingwithroby
@codingwithroby 2 месяца назад
Thanks for the feedback
@whereismypants69
@whereismypants69 Год назад
does the book id have to be an int or can i make it a string
@codingwithroby
@codingwithroby Год назад
It can anything you want it to be. Int, String, UUID you choose :)
Далее
How to build a FastAPI app with PostgreSQL
27:37
Просмотров 51 тыс.
PLEASE Use These 5 Python Decorators
20:12
Просмотров 115 тыс.
Why You NEED To Learn FastAPI | Hands On Project
21:15
Просмотров 164 тыс.
SQLAlchemy Makes Using Python Databases EASY
19:08
Просмотров 2,9 тыс.