Start here. This is the direct spoken answer to practice first.
Overview
Separates SQL synchronization from transaction completion and explains recovery after database errors.
flush() sends pending inserts, updates, and deletes to the database inside the current transaction, so generated keys and constraint errors can appear before commit. It does not make the transaction durable or visible under every isolation level. Autoflush is SQLAlchemy deciding to flush before operations such as an ORM query, commit, or savepoint. commit() flushes and commits; rollback() abandons the transaction's changes and resets its database work.