python-sqlalchemy

Implement SQLAlchemy 2.0 typed models and session handling for Python applications.

Updated Aug 29, 2025
One-click install
npx skills add https://github.com/DDTully/dotfiles --skill python-sqlalchemy-ddtully
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-sqlalchemy
Source: https://github.com/DDTully/dotfiles/tree/main/skills/.agent_skills/python-sqlalchemy
Command: npx skills add https://github.com/DDTully/dotfiles --skill python-sqlalchemy-ddtully

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Establishes consistent SQLAlchemy ORM patterns for Python applications, minimizing boilerplate and keeping data access predictable across projects.

Core Features & Use Cases

  • Typed model definitions using SQLAlchemy 2.0 APIs (Mapped and mapped_column) for strong typing and constraints.
  • Session and transaction management for both synchronous and asynchronous workflows, with best-practice commit/rollback handling.
  • Upsert patterns for PostgreSQL and JSON field handling to support real-world data models.

Quick Start

Create a minimal User model using Base and mapped_column, then open a session and insert a user.

Frequently Asked Questions about python-sqlalchemy

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

FAQPage Schema
How do I define typed SQLAlchemy ORM models using Mapped and mapped_column?

Define typed SQLAlchemy ORM models using the Mapped and mapped_column APIs from SQLAlchemy 2.0 to establish strong typing and database constraints. This approach minimizes boilerplate and keeps data access predictable across Python applications.

What's the best way to handle SQLAlchemy sessions in async Python applications?

Handle SQLAlchemy sessions in async Python applications by applying best-practice commit and rollback patterns. This ensures robust transaction management and predictable session lifecycles across both synchronous and asynchronous workflows.

How do I perform an upsert in SQLAlchemy for PostgreSQL?

Perform an upsert in SQLAlchemy for PostgreSQL by implementing dedicated upsert patterns designed for real-world data models. This handles insert and update operations seamlessly while managing JSON fields effectively.

Can I use SQLAlchemy 2.0 typed models with both sync and async workflows?

SQLAlchemy 2.0 typed models support both synchronous and asynchronous workflows. Session and transaction management patterns provide best-practice commit and rollback handling to ensure robust data access across different execution contexts.

How do I manage JSON fields and server defaults in SQLAlchemy ORM models?

Manage JSON fields and server defaults in SQLAlchemy ORM models by configuring mapped_column attributes during model definition. This supports real-world data models requiring flexible schema structures and automated default value generation.