SQLAlchemy and Alembic 2 · Querying

Insert rows

Add objects, then commit to write them.

with Session(engine) as session:
    ada = User(name="Ada", email="[email protected]")
    ada.posts.append(Post(title="Notes on engines"))
    session.add(ada)
    session.commit()

Official SQLAlchemy and Alembic 2 documentation

More querying commands

All querying commands · SQLAlchemy and Alembic 2 cheatsheet

Was this page helpful?