SQLAlchemy’s Session is a unit of work: you add and modify objects, and it emits the INSERT/UPDATE statements when it flushes, in dependency order. Commit makes them permanent; rollback discards them.