Why do Sqlalchemy Session.close not log “rollback”?

前端 未结 1 693
青春惊慌失措
青春惊慌失措 2020-12-22 08:25
# 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()         


        
相关标签:
1条回答
  • 2020-12-22 09:15

    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.

    0 讨论(0)
提交回复
热议问题