SQLAlchemy and Alembic 2 · Updating and raw SQL
Update many rows
Run one UPDATE statement for all matching rows.
from sqlalchemy import update
session.execute(update(User).where(User.email.is_(None)).values(email="unknown"))
session.commit()
Official SQLAlchemy and Alembic 2 documentation
More updating and raw sql commands
All updating and raw sql commands · SQLAlchemy and Alembic 2 cheatsheet