Building a REST API with FastAPI, Async SQLAlchemy, and PostgreSQL

preview_player
Показать описание
In this video, we shall be Building a REST API with FastAPI, Async SQLAlchemy, and PostgreSQL. We explore the Async SQLAlchemy 2.0 features and also some new features of Pydantic. We also use PostgreSQL as our data store for this project.

This video is an update to a video I made here.

SOURCE CODE:

PLEASE DONATE TO THE CHANNEL:

TIMESTAMPS:
(00:00) Introduction
(00:30) Project Setup
(01:49) Create a Fast API server
(07:41) simple API doc with SwaggerUi
(09:50) setup db with Async SQLAlchemy
(18:21) Creating database models
(27:40) Creating tables from the model in PostgreSQL
(33:01) Create, Retrieve, Update, And Delete
(48:09) Formatting code with black
(54:30) Create serializers with Pydantic
(58:20) List all note resources
(59:41) Create a note resource
(01:04:48) Customize the request body on SwaggerUI
(01:11:09) Retrieve a note resource
(01:13:12) Update a note resource
(01:19:31) Delete a note resource
(01:22:50) Conclusion
Рекомендации по теме
Комментарии
Автор

Hi guys! There are better approaches to creating the database connection. We can make a start up function or a lifespan event that will create the database connection on the app starting.

SsaliJonathan
Автор

Thanks Jonathan. Glad to see a FastAPI video with the latest SQLAlchemy way of defining models. Based on the comments below my next needs would also be alembic migrations, how to seed the database with data, and seeing some other object that has a relationship to the Notes object via foreign key (perhaps these are notes about a Video). One thing that nobody's FastAPI tutorial shows and would be very useful: If the database schema already exists, what is the way to build equivalent models and schemas from the existing tables. In many situations people are building apps that have to map from a db with tables and data already in it and seeing how to correctly work that way would be very helpful in the real-world.

marshall
Автор

Thanks sir!
For next video i'll wait your talk about Microservices and FastAPI

the-antroy
Автор

Hi everyone! This is one really unscripted video. Please expect to see me get bugs and also fix them. Thanks for watching. I appreciate.

SsaliJonathan
Автор

Great video! I really appreciate how thorough you are in describing everything.

cusematt
Автор

Exactly what I was looking for. Thank you for structured explanation and examples.

cupdkvq
Автор

Ah! The Exact Stack I was looking for, Thank You Jonathan!

pudasainiaashutosh
Автор

Thank you very much muganda wange for this video. I've learnt a lot from it.

martinmiz
Автор

excelente video amigo me has aclarado algunas dudas.

adonyslopez
Автор

Good content, keep in mind making more extensive videos from Fastapi, with jwt and more funcionality please

packo
Автор

This is an amazing video Jonnathan! keep it up, i try seting my own "id" to be auto_incremental_by 1, but i couldn't while coding along side with you🤔

timothyatanda
Автор

'AsyncEngine' object is not callable why ??

diegomazorra
Автор

have you listen about Alchemical? it simplify SQLAlchemy session, engine, etc. By the way great tutorial, thx

dannisisgt
Автор

Any plans on integrating the alembic in the project? By the way the video covers everything, but would be good how to add soft delete and how we deploy this and how we can have continuous integration.

jijojoseph
Автор

you create databse with python comand python3 db.py but in production we need to use somwthing like we use before sqlalchemy 2.0 can you help me what to use now

udaym
Автор

In most tutorials the database connection is done with the dependency injection that comes with fastapi. the reason you don't use it is because you are writing asynchronously?

oktay
Автор

why are we using the async version of sqlalchemy?

razapanjwani