SQLAlchemy and Alembic 2 · Querying

Select rows

Build a select statement and read model objects with scalars().

from sqlalchemy import select

with Session(engine) as session:
    users = session.scalars(select(User).where(User.name == "Ada").order_by(User.id)).all()

Official SQLAlchemy and Alembic 2 documentation

More querying commands

All querying commands · SQLAlchemy and Alembic 2 cheatsheet

Was this page helpful?