What problem does it solve?
This Skill helps developers implement robust async SQLAlchemy data access patterns for FastAPI projects, covering models, sessions, queries, migrations, and transactional workflows to ensure scalable and safe database interactions.
Core Features & Use Cases
- Engine and session setup with AsyncSession and engine configuration, including expire_on_commit handling.
- Base model structure with a TimestampMixin to standardize timestamps across entities.
- Declarative models and relationships using SQLAlchemy 2.x style with proper lazy loading safeguards.
- Async queries, bulk operations, and Alembic-based migrations to evolve schema safely in FastAPI projects.
- Guidance on common pitfalls (N+1 queries, proper eager loading, and transaction boundaries).
Quick Start
Define an async engine, an AsyncSession factory, and a sample model with Alembic migrations to start using SQLAlchemy 2.x in FastAPI.