Overview
SQLAlchemy has been developed by its authors and contributors since at least 2007 (the start of its copyright notice) and is the most widely used database library in Python. Core gives you a SQL expression language, schema metadata and connection pooling; the ORM adds declarative mapped classes, relationships, a Session with identity map and unit of work, and many loading strategies. Since 2.0, queries use a unified select() style with type-annotated Mapped[] columns that editors and type checkers understand.
Schema migrations are handled by Alembic, a separate tool from the same project, which can autogenerate migration scripts by comparing models with the database; its docs describe what autogenerate does and does not detect.
SQLAlchemy 2.1.0 was released on 24 September 2026, three years after 2.0. It requires Python 3.11, no longer installs greenlet by default (install sqlalchemy[asyncio] for async), defaults postgresql:// URLs to psycopg 3 and oracle:// to oracledb, and adds t-string SQL, CREATE VIEW support and Microsoft's mssql-python driver. The project says the upgrade is far smaller than 1.4 to 2.0.
Pricing and plans
| Plan | Price | What you get |
|---|---|---|
| SQLAlchemy | $0 | MIT licence |
What it does
- Core expression language
- Build SQL with Python objects, independent of the ORM, with full control over the statement.
- ORM with unit of work
- Session tracks changes to mapped objects and flushes them in dependency order.
- Typed mappings
- Declarative classes with Mapped[] annotations are understood by mypy and IDEs.
- Asyncio support
- AsyncEngine and AsyncSession for asyncpg, psycopg and other async drivers (install the asyncio extra in 2.1).
- Alembic migrations
- Autogenerate revision scripts from model changes, branch and merge revisions, and generate offline SQL.
- Many dialects
- Built-in PostgreSQL, MySQL/MariaDB, SQLite, Oracle and SQL Server, plus external dialects for Snowflake, BigQuery, ClickHouse, CockroachDB and more.
Strengths and limitations
Strengths
- Mature and extremely well documented, with two decades of production use
- Lets you drop to Core SQL whenever the ORM gets in the way
- Wide dialect coverage through built-in and third-party dialects
- Foundation for SQLModel, Flask-SQLAlchemy and many other tools
Limitations
- Large API with two layers (Core and ORM) and many loading options, so the learning curve is steep
- Migrations need a separate tool (Alembic), and autogenerate does not detect every change
- Async support relies on greenlet, which 2.1 no longer installs by default
- 2.1 requires Python 3.11 or newer
Who it suits
Good for
- Python web apps on FastAPI, Flask or Starlette
- Data-heavy services that mix ORM and hand-written SQL
- Teams that need Oracle, SQL Server or unusual databases from Python
Look elsewhere if
- Django projects, which have their own ORM
- Very small scripts where a lighter library such as Peewee is enough
Pricing history
-
SQLAlchemy 2.1 released
SQLAlchemy 2.1.0 requires Python 3.11, no longer installs greenlet by default, defaults to psycopg 3 and oracledb, and adds t-string SQL, CREATE VIEW and the mssql-python driver. Source ↗
Alternatives to SQLAlchemy
| Tool | From | Free option | Stages |
|---|---|---|---|
| Active Record (Rails) Active Record ORM for Ruby on Rails | — | ||
| Eloquent ORM Active Record ORM for Laravel | — | ||
| Dapper .NET micro-ORM | — | ||
| Entity Framework Core .NET ORM | — | ||
| Hibernate ORM Java ORM and Jakarta Persistence implementation | — | ||
| Doctrine ORM Data mapper ORM for PHP | — |
Questions
How do I do migrations with SQLAlchemy?
Use Alembic, the migration tool from the same project; it can autogenerate revision scripts from your models.
What changed in SQLAlchemy 2.1?
Python 3.11 minimum, greenlet no longer installed by default, psycopg 3 and oracledb as default drivers, plus t-string SQL, CREATE VIEW and the mssql-python driver.
Does SQLAlchemy support async?
Yes, through AsyncEngine and AsyncSession; in 2.1 install sqlalchemy[asyncio] to get the greenlet dependency.
SQLAlchemy vs SQLModel: which should I use?
SQLModel is a thinner layer on SQLAlchemy and Pydantic for FastAPI apps; SQLAlchemy exposes the full feature set directly.
Sources read for this page