SQLAlchemy and Alembic 2 · Querying

Join tables

Select columns across a relationship with an explicit join.

stmt = select(User.name, Post.title).join(Post, Post.user_id == User.id)
rows = session.execute(stmt).all()

Official SQLAlchemy and Alembic 2 documentation

More querying commands

All querying commands · SQLAlchemy and Alembic 2 cheatsheet

Was this page helpful?