$npx skillfedfor your agent

sqlalchemy

SQLAlchemy equips Python developers with a robust SQL toolkit and ORM for building type-safe database applications. Master declarative models, relationship mapping, efficient query patterns, and async support using SQLAlchemy 2.0's modern API.

SQLAlchemy teaches Python SQL toolkit and ORM fundamentals with modern 2.0 patterns and best practices.

AI-generated summary based on this skill's SKILL.md

62 18 MITupdated by bobmatnyc

Decision gist · record as of 2026-07-18

SQLAlchemy teaches Python SQL toolkit and ORM fundamentals with modern 2.0 patterns and best practices. SQLAlchemy equips Python developers with a robust SQL toolkit and ORM for building type-safe database applications. Master declarative models, relationship mapping, efficient query patterns, and async support using SQLAlchemy 2.0's modern API.

manual: git clone https://github.com/bobmatnyc/claude-mpm-skills → cp -r claude-mpm-skills/toolchains/python/data/sqlalchemy ~/.claude/skills/sqlalchemy
toolchains/python/data/sqlalchemy/SKILL.md · version 1f55dbdf

Use it when

  • SQLAlchemy integrates with FastAPI by creating a database engine, configuring a session factory.
  • SQLAlchemy 2.0 uses the `select()` constructor for composable queries.

Verify before relying

Read SKILL.md below before installing (3 files). Open directory: indexed for reading, not audited.

Same gist for agents: .md · .json

Install

bobmatnyc/claude-mpm-skills/sqlalchemy · repository language: Python

Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

What is SQLAlchemy and how do I query with it?

SQLAlchemy equips Python developers with a robust SQL toolkit and ORM for building type-safe database applications. You query using the modern 2.0 API with `select()` statements, define models as declarative classes inheriting from `DeclarativeBase`, and execute queries through sessions. SQLAlchemy handles SQL generation, relationship mapping, and database abstraction across multiple backends.

How do I use SQLAlchemy with FastAPI?

SQLAlchemy integrates with FastAPI by creating a database engine, configuring a session factory, and injecting sessions into route handlers via dependency injection. Define your models using declarative syntax, create async sessions with `AsyncSession`, and use them in FastAPI endpoints to perform CRUD operations. This pattern keeps your routes clean and testable.

What are SQLAlchemy 2.0 select query examples?

SQLAlchemy 2.0 uses the `select()` constructor for composable queries. Basic example: `select(User).where(User.age > 18)`. Join multiple tables with `select(User, Post).join(Post)`. Filter with `.where()`, order with `.order_by()`, and limit results with `.limit()`. The API is chainable and type-safe, replacing the legacy query interface.

How do I solve the SQLAlchemy N+1 problem with eager loading?

SQLAlchemy's N+1 problem occurs when loading related objects triggers extra queries. Solve it using eager loading strategies: `selectinload()` executes a second query to load relationships, `joinedload()` uses a single JOIN, and `contains_eager()` works with explicit joins. Import from `sqlalchemy.orm` and apply to your select: `select(User).options(selectinload(User.posts))`.

How do I set up database migrations with Alembic?

SQLAlchemy works with Alembic for schema management. Initialize Alembic with `alembic init`, configure your database URL in `alembic.ini`, and set `sqlalchemy.url`. Define your models, then auto-generate migrations with `alembic revision --autogenerate -m 'message'`. Review the generated migration file, then apply changes with `alembic upgrade head`.

What are SQLAlchemy session management best practices?

SQLAlchemy session management best practices include using context managers (`with Session() as session:`), keeping sessions scoped to request lifecycles in web apps, avoiding session sharing across threads, and committing or rolling back explicitly. Use `sessionmaker` to create a factory, configure connection pooling for performance, and always close sessions to return connections to the pool.

SKILL.md

Rendered from the published skill. Quoted content, verbatim.

SQLAlchemy ORM Skill


progressive_disclosure: entry_point: summary: "Python SQL toolkit and ORM with powerful query builder and relationship mapping" when_to_use: - "When building Python applications with databases" - "When needing complex SQL queries with type safety" - "When working with FastAPI/Flask/Django" - "When needing database migrations (Alembic)" quick_start: - "pip install sqlalchemy" - "Define models with declarative base" -

(truncated - see the full file via the links below)

File tree — 3 files
toolchains/python/data/sqlalchemy/SKILL.md
toolchains/python/data/sqlalchemy/metadata.json
toolchains/python/data/sqlalchemy/references/sql-quality-antipatterns.md

Let your AI agent find skills like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.

wish › “Learn SQLAlchemy ORM fundamentals and modern 2.0 API patterns”

Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →

Related skills

Sqlmodel Expert
by bilalmk · bilalmk/todo_correct

Build robust database layers with SQLModel patterns for one-to-many, many-to-many, and self-referential relationships. Manage schema evolution safely using Alembic migrations, from autogenerated changes to complex data transformations. Includes query optimization techniques, inheritance patterns, and production-ready helper scripts.

no license declared → metadata onlyfor claude-codeupdated Jan 2026
★ 1repo stars
Sqlalchemy Patterns
by majesticlabs-dev · majesticlabs-dev/majestic-marketplace

This skill teaches SQLAlchemy 2.0 design patterns for building database applications in Python. It covers engine configuration, typed model definitions, relationship patterns, query optimization techniques, and the repository pattern for clean data access layers.

no license declared → metadata onlyupdated May 2026
★ 44repo stars
Fastapi
by manutej · manutej/luxor-claude-marketplace

Master FastAPI for building scalable customer support APIs with async request handling, dependency injection, and Pydantic validation. Learn database integration with PostgreSQL, WebSocket real-time capabilities, authentication patterns, and background task management. This intermediate-to-advanced skill covers the complete lifecycle from endpoint design to production deployment.

no license declared → metadata onlyupdated Jun 2026
★ 61repo stars
Sqlalchemy
by manutej · manutej/luxor-claude-marketplace

SQLAlchemy ORM Expert covers modern ORM patterns, session handling, and query performance tuning tailored for customer support systems. Learn to design robust data models with relationships, leverage async operations in FastAPI, and integrate PostgreSQL effectively. The skill walks through real support scenarios including ticket management, user authentication, and bulk data operations.

no license declared → metadata onlyupdated Jun 2026
★ 61repo stars
Python Backend Expert
by hieutrtr · hieutrtr/ai1-skills

Python Backend Expert guides implementation of FastAPI endpoints, SQLAlchemy models, Pydantic schemas, and layered architecture with repositories and services. It covers async session management, dependency injection, error handling, and database migrations for Python 3.12+ projects.

no license declared → metadata onlyupdated Feb 2026
★ 8repo stars
sqlalchemy-postgres
by cfircoo · cfircoo/claude-code-toolkit

This skill provides expert guidance for building production-ready database layers using SQLAlchemy 2.0 with async support, Pydantic v2 validation, and PostgreSQL. It covers initialization, model definition with type-safe annotations, Alembic migrations, async CRUD patterns, and repository architecture for clean separation of concerns.

MITupdated Mar 2026
★ 17repo stars

More skills python-backend (MIT) · supabase-python (MIT) · Fastapi Expert (Unlicense) · System Architecture (unlicensed) · Alembic (unlicensed) · Alembic Patterns (NOASSERTION) · Data Engineering (unlicensed) · database-migration-patterns (Apache-2.0)

Tags
object-relational-mappingdatabase-abstraction-layerasync-database-accessschema-versioningconnection-poolingquery-optimizationdata-persistenceorm-relationshipsmigration-managementtype-safe-queries