FastAPI & SQLModel - Database Interaction in FastAPI apps with SQLModel

preview_player
Показать описание
In this video, we refactor the Pydantic models from the previous video into SQLModel classes that can interact with our database and define the schema of our tables.

We'll see how to re-write our FastAPI handler functions to use this database.

☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:

📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
00:35 SQLModel intro
05:18 Create relationships between SQLModel classes
08:18 Creating database connection
13:04 Using database in FastAPI handler functions

▶️ Full Playlist:

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:

📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:

#python #fastapi #webdevelopment
Рекомендации по теме
Комментарии
Автор

Can you show hoz to set up FastAPI with MySQL and PostGreSQL (especially with the async features)?

thierryyolepiot
Автор

This is incredibly well produced and deeply informative. Thank you.

dixone
Автор

Lots of value in this video, thanks!!

opticonor
Автор

also setting up with postgres docker and traefik .Also an additional content can be sending emails and show how to create email templates

djtoon
Автор

Why should one create subclasses and inherit from a base class? Is there a reason you shouldn't just, for example, put the primary key field in the parent class?

Steve
Автор

Is SQLModel still necessary with SQLAlchemy 2.0?

catchychazz
Автор

A video on env config and file structure for bigger projects would also be helpful

ayushshende
Автор

Please do more on the crud operations as well as error handlings please

recaseng
Автор

Great content! Can you please explain why some tutorials use pydantic models(schemas) AND sql models (models)? I find this confusing and causing issues.

tascsolutions
Автор

Endpoint functions are defined as `async def`, but the db operations inside are all sync, including the get_session depency. This is bad in a real project. async def endpoints are running in an event loop, time cosuming db operations are not awaited, so they will block the event loop.

juvewan
Автор

can we also get one for microservices using gRPC

djtoon
Автор

Instead of converting the type to a string, you can do `from __future__ import annotations`

farzadmf
Автор

Hey, do you consider making an unpoly video? I feel like the library is so underrated.

beefbox
Автор

Timestamp: 18:30. Even after adding `None` to the `band_id` at runtime I'm getting "pydantic_core: 1 validation error for AlbumBase" "band_id missing". I am using Progres instead of SQLite.

gerrior
Автор

restAPI, sqlmodel, alembic. docker .compose and metrics

alexandrodisla