sqlalchemy

Installation
SKILL.md

SQLAlchemy

Overview

SQLAlchemy is the standard Python ORM and SQL toolkit. The 2.x API is type-friendly and has first-class asyncio support: define models as Python classes with Mapped[...] annotations, write queries with select(), and manage schema changes with Alembic migrations.

The current release line is 2.1 (2.1.1, September 2026); 2.0.x (last seen: 2.0.54) is the line for Python older than 3.11. What 2.1 changes for existing 2.0 code:

  • Python 3.11 is the minimum.
  • greenlet is no longer installed by default. Async code needs pip install "sqlalchemy[asyncio]", otherwise importing sqlalchemy.ext.asyncio raises ImportError.
  • A URL without a driver, postgresql://..., now selects psycopg 3 instead of psycopg2. Write postgresql+psycopg2:// to keep the old driver. Oracle likewise defaults to python-oracledb.
  • select(a, b) is typed Select[int, str] instead of Select[Tuple[int, str]] (needs mypy 1.7+).
  • The session autoflushes before every statement, including text() and Core statements.

Instructions

Step 1: Async Setup

Installs
7
GitHub Stars
197
First Seen
Mar 13, 2026