Skip to content Skip to sidebar Skip to footer

Why Do Sqlalchemy Session.close Not Log "rollback"?

# I've set echo=True when doing create_engine, so I can see all the sql stmt # DBSession is ScopeSession(thread_local) and autocommit is False session = DBSession() session.add(so

Solution 1:

the rollback (or if configured, the commit) that occurs in the Pool is not currently participating in the logging that the Engine normally does for commit/rollback events.

ticket: http://www.sqlalchemy.org/trac/ticket/2752 has been added.

Edit: Took a look at this, and I think this logging should still be part of the pool's logger, not the engine's, otherwise you get a lot of this:

sqlalchemy.Engine: COMMIT
sqlalchemy.Engine: ROLLBACK (via pool)

An application really shouldn't have to worry too much about the pool's rollback of things, because if you're using a Session, you really should be calling commit() or rollback() right before any close() operation.

the pool logging is turned on normally by create_engine("url", echo_pool='debug'), or setting up logging on the sqlalchemy.pool namespace.


Post a Comment for "Why Do Sqlalchemy Session.close Not Log "rollback"?"