FastAPI Users DB SQLAlchemy
SQLAlchemy database adapter for the FastAPI Users auth library.
Repository Health
Technical Analysis
fastapi-users-db-sqlalchemy is the SQLAlchemy ORM database adapter for FastAPI Users, the ready-to-use user-management and authentication library for FastAPI. It provides the concrete persistence layer that FastAPI Users needs to create, read, update, and delete user accounts, plus the SQLAlchemy model mixins and table definitions for users and OAuth accounts.
By implementing FastAPI Users’ database-adapter protocol against async SQLAlchemy, this package lets you back your authentication system with any SQLAlchemy-supported database (PostgreSQL, MySQL, SQLite, and more) while keeping the FastAPI Users API unchanged. It is one of several official adapters, alongside Beanie/MongoDB, so you can swap storage backends without rewriting your auth code.
What You Get
SQLAlchemyUserDatabase, the adapter implementing FastAPI Users’ database protocolSQLAlchemyBaseUserTableand related mixins defining the user table schema- OAuth-account table base for storing linked social-login accounts
- Async SQLAlchemy support so it fits FastAPI’s asynchronous request model
- Compatibility with any SQLAlchemy-supported database engine
Common Use Cases
- Persisting FastAPI Users accounts in PostgreSQL, MySQL, or SQLite
- Adding SQLAlchemy-backed authentication to a FastAPI application
- Storing OAuth/social-login account links alongside user records
- Extending the base user model with custom columns for your app
Under The Hood
Architecture — The package defines declarative SQLAlchemy base classes (SQLAlchemyBaseUserTable, OAuth-account base) that applications subclass to create their concrete user models, and a SQLAlchemyUserDatabase class that implements the FastAPI Users database-adapter interface. FastAPI Users calls the adapter’s async methods (get by id/email, create, update, delete, OAuth lookups), which translate into SQLAlchemy queries executed against a provided async session.
Tech Stack — Pure Python built on SQLAlchemy (async ORM) and typed against FastAPI Users’ adapter protocol. It targets modern Python versions and is packaged for PyPI with GitHub Actions CI and Codecov coverage.
Code Quality — A small, focused adapter (about 70 commits, 7 releases) that is heavily depended upon (~311K weekly downloads) as part of the FastAPI Users ecosystem. Development is low-activity because the surface is stable and largely complete; CI and coverage are configured.
API Design — The adapter keeps the FastAPI Users API identical regardless of backend: you subclass the provided table bases, wire up a SQLAlchemyUserDatabase with your async session, and hand it to FastAPI Users. Swapping to a different official adapter requires changing only the persistence wiring, not your auth routes.