SQLAlchemy - Is it necessary to commit after session.execute()?
Updated 2026-07-16: updated the answer and links for SQLAlchemy 2.0.
Session.execute runs its statement within the current transaction, and SQLAlchemy’s autobegin starts that transaction on first use.
So if the statement writes (INSERT, UPDATE, DELETE), yes, you need to commit(), or the transaction rolls back when the session closes. A read-only SELECT changes nothing, so there is nothing to commit.
Here’s a code example along with the output from echo=True, showing the session begins a transaction but doesn’t end it until you run session.commit():