python-database-patterns — community python-database-patterns, PyAgent, community, ide skills, Claude Code, Cursor, Windsurf

v1.0.0

About this Skill

Perfect for Python Database Agents needing advanced SQLAlchemy 2.0 integration for database management and optimization. SQLAlchemy and database patterns for Python. Triggers on: sqlalchemy, database, orm, migration, alembic, async database, connection pool, repository pattern, unit of work.

UndiFineD UndiFineD
[4]
[0]
Updated: 3/6/2026

Killer-Skills Review

Decision support comes first. Repository text comes second.

Reviewed Landing Page Review Score: 9/11

Killer-Skills keeps this page indexable because it adds recommendation, limitations, and review signals beyond the upstream repository text.

Original recommendation layer Concrete use-case guidance Explicit limitations and caution Quality floor passed for review Locale and body language aligned
Review Score
9/11
Quality Score
51
Canonical Locale
en
Detected Body Locale
en

Perfect for Python Database Agents needing advanced SQLAlchemy 2.0 integration for database management and optimization. SQLAlchemy and database patterns for Python. Triggers on: sqlalchemy, database, orm, migration, alembic, async database, connection pool, repository pattern, unit of work.

Core Value

Empowers agents to interact with databases using SQLAlchemy 2.0, providing declarative base classes, mapped columns, and session management, while following database best practices and utilizing libraries like sqlalchemy.orm.

Ideal Agent Persona

Perfect for Python Database Agents needing advanced SQLAlchemy 2.0 integration for database management and optimization.

Capabilities Granted for python-database-patterns

Automating database schema creation
Generating database queries using select and mapped_column
Debugging database connections with create_engine and Session

! Prerequisites & Limits

  • Requires SQLAlchemy 2.0 installation
  • Python 3.x compatibility required

Source Boundary

The section below is supporting source material from the upstream repository. Use the Killer-Skills review above as the primary decision layer.

Labs Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

FAQ & Installation Steps

These questions and steps mirror the structured data on this page for better search understanding.

? Frequently Asked Questions

What is python-database-patterns?

Perfect for Python Database Agents needing advanced SQLAlchemy 2.0 integration for database management and optimization. SQLAlchemy and database patterns for Python. Triggers on: sqlalchemy, database, orm, migration, alembic, async database, connection pool, repository pattern, unit of work.

How do I install python-database-patterns?

Run the command: npx killer-skills add UndiFineD/PyAgent/python-database-patterns. It works with Cursor, Windsurf, VS Code, Claude Code, and 19+ other IDEs.

What are the use cases for python-database-patterns?

Key use cases include: Automating database schema creation, Generating database queries using select and mapped_column, Debugging database connections with create_engine and Session.

Which IDEs are compatible with python-database-patterns?

This skill is compatible with Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer. Use the Killer-Skills CLI for universal one-command installation.

Are there any limitations for python-database-patterns?

Requires SQLAlchemy 2.0 installation. Python 3.x compatibility required.

How To Install

  1. 1. Open your terminal

    Open the terminal or command line in your project directory.

  2. 2. Run the install command

    Run: npx killer-skills add UndiFineD/PyAgent/python-database-patterns. The CLI will automatically detect your IDE or AI agent and configure the skill.

  3. 3. Start using the skill

    The skill is now active. Your AI agent can use python-database-patterns immediately in the current project.

Imported Repository Instructions

The section below is supporting source material from the upstream repository. Use the Killer-Skills review above as the primary decision layer.

Supporting Evidence

python-database-patterns

Install python-database-patterns, an AI agent skill for AI agent workflows and automation. Works with Claude Code, Cursor, and Windsurf with one-command...

SKILL.md
Readonly
Imported Repository Instructions
The section below is supporting source material from the upstream repository. Use the Killer-Skills review above as the primary decision layer.
Supporting Evidence

Python Database Patterns

SQLAlchemy 2.0 and database best practices.

SQLAlchemy 2.0 Basics

python
1from sqlalchemy import create_engine, select 2from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, Session 3 4class Base(DeclarativeBase): 5 pass 6 7class User(Base): 8 __tablename__ = "users" 9 10 id: Mapped[int] = mapped_column(primary_key=True) 11 name: Mapped[str] = mapped_column(String(100)) 12 email: Mapped[str] = mapped_column(String(255), unique=True) 13 is_active: Mapped[bool] = mapped_column(default=True) 14 15# Create engine and tables 16engine = create_engine("postgresql://user:pass@localhost/db") 17Base.metadata.create_all(engine) 18 19# Query with 2.0 style 20with Session(engine) as session: 21 stmt = select(User).where(User.is_active == True) 22 users = session.execute(stmt).scalars().all()

Async SQLAlchemy

python
1from sqlalchemy.ext.asyncio import ( 2 AsyncSession, 3 async_sessionmaker, 4 create_async_engine, 5) 6from sqlalchemy import select 7 8# Async engine 9engine = create_async_engine( 10 "postgresql+asyncpg://user:pass@localhost/db", 11 echo=False, 12 pool_size=5, 13 max_overflow=10, 14) 15 16# Session factory 17async_session = async_sessionmaker(engine, expire_on_commit=False) 18 19# Usage 20async with async_session() as session: 21 result = await session.execute(select(User).where(User.id == 1)) 22 user = result.scalar_one_or_none()

Model Relationships

python
1from sqlalchemy import ForeignKey 2from sqlalchemy.orm import relationship, Mapped, mapped_column 3 4class User(Base): 5 __tablename__ = "users" 6 7 id: Mapped[int] = mapped_column(primary_key=True) 8 name: Mapped[str] 9 10 # One-to-many 11 posts: Mapped[list["Post"]] = relationship(back_populates="author") 12 13class Post(Base): 14 __tablename__ = "posts" 15 16 id: Mapped[int] = mapped_column(primary_key=True) 17 title: Mapped[str] 18 author_id: Mapped[int] = mapped_column(ForeignKey("users.id")) 19 20 # Many-to-one 21 author: Mapped["User"] = relationship(back_populates="posts")

Common Query Patterns

python
1from sqlalchemy import select, and_, or_, func 2 3# Basic select 4stmt = select(User).where(User.is_active == True) 5 6# Multiple conditions 7stmt = select(User).where( 8 and_( 9 User.is_active == True, 10 User.age >= 18 11 ) 12) 13 14# OR conditions 15stmt = select(User).where( 16 or_(User.role == "admin", User.role == "moderator") 17) 18 19# Ordering and limiting 20stmt = select(User).order_by(User.created_at.desc()).limit(10) 21 22# Aggregates 23stmt = select(func.count(User.id)).where(User.is_active == True) 24 25# Joins 26stmt = select(User, Post).join(Post, User.id == Post.author_id) 27 28# Eager loading 29from sqlalchemy.orm import selectinload 30stmt = select(User).options(selectinload(User.posts))

FastAPI Integration

python
1from fastapi import Depends, FastAPI 2from sqlalchemy.ext.asyncio import AsyncSession 3from typing import Annotated 4 5async def get_db() -> AsyncGenerator[AsyncSession, None]: 6 async with async_session() as session: 7 yield session 8 9DB = Annotated[AsyncSession, Depends(get_db)] 10 11@app.get("/users/{user_id}") 12async def get_user(user_id: int, db: DB): 13 result = await db.execute(select(User).where(User.id == user_id)) 14 user = result.scalar_one_or_none() 15 if not user: 16 raise HTTPException(status_code=404) 17 return user

Quick Reference

OperationSQLAlchemy 2.0 Style
Select allselect(User)
Filter.where(User.id == 1)
First.scalar_one_or_none()
All.scalars().all()
Countselect(func.count(User.id))
Join.join(Post)
Eager load.options(selectinload(User.posts))

Additional Resources

  • ./references/sqlalchemy-async.md - Async patterns, session management
  • ./references/connection-pooling.md - Pool configuration, health checks
  • ./references/transactions.md - Transaction patterns, isolation levels
  • ./references/migrations.md - Alembic setup, migration strategies

Assets

  • ./assets/alembic.ini.template - Alembic configuration template

See Also

Prerequisites:

  • python-typing-patterns - Mapped types and annotations
  • python-async-patterns - Async database sessions

Related Skills:

  • python-fastapi-patterns - Dependency injection for DB sessions
  • python-pytest-patterns - Database fixtures and testing

Related Skills

Looking for an alternative to python-database-patterns or another community skill for your workflow? Explore these related open-source skills.

View All

openclaw-release-maintainer

Logo of openclaw
openclaw

Your own personal AI assistant. Any OS. Any Platform. The lobster way. 🦞

333.8k
0
AI

widget-generator

Logo of f
f

Generate customizable widget plugins for the prompts.chat feed system

149.6k
0
AI

flags

Logo of vercel
vercel

The React Framework

138.4k
0
Browser

pr-review

Logo of pytorch
pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration

98.6k
0
Developer