Best approach for async SQLAlchemy in FastAPI

I'd say either encode/databases or sqlalchemy asyncio

Using non-asyncio sqlalchemy will be a performance bottleneck except for small workloads as every db operation needs to either block the event loop or run in a thread.

Sqlalchemy asyncio uses the real asyncio event loop and works with real asyncio db drivers such as asyncpg. There's no monkey patching or anything like that.

There is some trickery with a single greenlet to context switch internally to facilitate implicit IO, but all communication with the db runs on the asyncio event loop. Essentially a way to avoid rewriting the whole framework with async/await keywords.

That's from what I understand, I've just been casually following zzzek's posts on this but haven't used it in any real projects yet.

In my current fastapi projects I'm using encode/databases. You can use most of sqlalchemy core with it which is great.
CRUD only gets slightly repetitive without an ORM, but it's not too bad.

/r/FastAPI Thread