SQLAlchemy 2.0 Patterns

•
37
•

Implements modern SQLAlchemy 2.0 patterns for database modeling, asynchronous queries, and efficient data access.

This skill provides a comprehensive suite of SQLAlchemy 2.0 implementation patterns designed to streamline Python database development. It covers everything from modern engine configuration and DeclarativeBase model definitions to advanced concepts like asynchronous session management, complex relationship mapping, and the Repository pattern. Whether you are building high-performance FastAPI applications or refactoring legacy code, this skill helps you apply industry best practices for query optimization, N+1 prevention, and robust transaction handling.

主要功能

01Advanced relationship patterns including self-referential and many-to-many
0237 GitHub stars
03Query optimization strategies using eager loading (selectinload/joinedload)
04Asynchronous engine and session management for PostgreSQL
05Generic Repository pattern implementation for cleaner architecture
06Modern SQLAlchemy 2.0 Mapped and mapped_column syntax

使用场景

01Building scalable backend services with FastAPI and PostgreSQL
02Refactoring existing Python projects to SQLAlchemy 2.0 standards
03Implementing complex data relationships and optimized batch operations