The most widely used Python SQL toolkit and ORM. v2.0 released January 2023 — massive breaking change from v1.x. The entire ORM query API shifted from session.query() to select(). engine.execute() removed. Passing raw strings to execute() removed. Typed mapped_column() replaces Column(). Current version: 2.0.48 (Mar 2026). Flask-SQLAlchemy's Model.query pattern is also legacy in v2.
Install & Compatibility
Where this runs
tested against v2.0.50 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.950 runs
installs and imports cleanly · install 0.0s · import 0.684s · 42.5MB
glibcpy 3.10–3.950 runs
installs and imports cleanly · install 3.2s · import 0.616s · 41MB
41MB installed
● package 41MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from sqlalchemy import select
from sqlalchemy.orm import Session
SQLAlchemy 2.0 ORM quickstart with typed models.
# pip install sqlalchemy
from sqlalchemy import create_engine, String, select, text
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, Session
class Base(DeclarativeBase):
pass
class User(Base):
__tablename__ = 'users'
id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column(String(50))
engine = create_engine('sqlite:///test.db')
Base.metadata.create_all(engine)
with Session(engine) as session:
# Insert
session.add(User(name='Alice'))
session.commit()
# Query — v2 style
stmt = select(User).where(User.name == 'Alice')
user = session.scalars(stmt).first()
print(user.name) # 'Alice'
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.