sqlalchemy-patterns

Design SQLAlchemy 2.0 ORM models, async sessions, repositories, and Alembic migrations.

46|8|Updated Mar 25, 2026
One-click install
npx skills add https://github.com/manikosto/claude-code-python-stack --skill sqlalchemy-patterns-manikosto
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sqlalchemy-patterns
Source: https://github.com/manikosto/claude-code-python-stack/tree/main/skills/sqlalchemy-patterns
Command: npx skills add https://github.com/manikosto/claude-code-python-stack --skill sqlalchemy-patterns-manikosto

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Build robust, maintainable data access layers for Python apps using SQLAlchemy 2.0 patterns including ORM models, async sessions, relationships, and migrations.

Core Features & Use Cases

  • ORM model patterns with mixins and base classes
  • Async session setup and repository pattern for clean data access
  • Relationship handling and advanced query patterns
  • Alembic migrations workflow and performance tips

Quick Start

Create an async SQLAlchemy data layer with a Base model, a sample User repository, and an Alembic migration workflow using the patterns shown.

Frequently Asked Questions about sqlalchemy-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up async sessions in SQLAlchemy 2.0?

Async sessions in SQLAlchemy 2.0 are set up using the repository pattern to cleanly separate data access logic from your Python web application's business logic. This approach establishes maintainable asynchronous database interactions.

What's the best way to structure ORM models for maintainability in SQLAlchemy 2.0?

The best way to structure SQLAlchemy 2.0 ORM models for maintainability is using mixins and base classes. This pattern ensures cohesive data layers and promotes reusable relationship handling across your application.

How do Alembic migrations work with SQLAlchemy 2.0 patterns?

Alembic migrations integrate with SQLAlchemy 2.0 patterns by providing a structured workflow for evolving your database schema. They enable version-controlled schema changes alongside ORM model updates and performance tips.

Can I use the repository pattern with async SQLAlchemy 2.0 sessions?

Yes, the repository pattern is explicitly designed for use with async SQLAlchemy 2.0 sessions. It abstracts query strategies and data access operations, resulting in a clean separation between persistence logic and domain logic.

When do I need advanced query patterns in SQLAlchemy 2.0?

Advanced query patterns in SQLAlchemy 2.0 are needed when handling complex relationship loading and optimizing database performance. These patterns provide targeted query strategies to efficiently retrieve nested data without causing bottlenecks.