Agent skill · software engineering · aiskillstore
py-sqlmodel-patterns
SQLModel and async SQLAlchemy patterns. Use when working with database models, queries, relationships, or debugging ORM issues.
Why this skill is useful
Provides specific patterns and examples for using SQLModel and async SQLAlchemy that the AI wouldn't reliably generate on its own.
What it needs
About 4k tokens when loaded. Last updated 2026-08-07. 405 stars on the source repository.
What this skill does
SQLModel Patterns Problem Statement SQLModel combines Pydantic and SQLAlchemy, blurring the line between models and schemas. Async SQLAlchemy has different rules than sync. Mistakes here cause data corruption, N+1 queries, and hard-to-debug errors. --- Pattern: Eager Loading for Async Problem: Lazy loading doesn't work with async SQLAlchemy. Accessing relationships without eager loading raises errors. When to use which: Relationship Loading Strategy -------------- ------------------ One-to-many (collections) selectinload() Many-to-one (single) joinedload() Nested relationships Chain: .options(selectinload(A.b).selectinload(B.c)) --- Pattern: N+1 Query Detection Problem: Fetching related objects one-by-one instead of in batch. --- Pattern: Model vs Schema Separation Problem: SQLModel blurs models (DB) and schemas (API). Need clear separation. Naming convention: ModelName - Database table model ModelNameCreate - Input for creation ModelNameRead - Output for reading ModelNameUpdate - Input for partial updates --- Pattern: Session State Management Problem: Understanding expireoncommit and when objects become stale. --- Pattern: UUID Handling Problem: Inconsistent UUID handling between Python and PostgreSQL. --- Pattern: Nullable Fields Problem: SQLModel requires specific syntax for optional fields. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills aiskillstore/py-sqlmodel-patterns