Paul's Programming Notes     Archive     Feed     Github

SQLAlchemy - Is is necessary to commit after session.execute?

The docs for session.execute say:

Execute a SQL expression construct or string statement within the current transaction.

So, the answer is yes, you need to issue a commit after running session.execute().

Here’s a code example along with the output from “echo=True” showing it begins the session but doesn’t end it unless you run session.commit():