def commit(self, *args, **kwargs): ses = self.session() try: xid = ses.query(func.txid_current()).first() logger.info("Transaction id: %s" % xid) logger.debug("Commit") except Exception as e: logger.exception(e) return ses.commit(*args, **kwargs)
def rollback(): """ Do database rollback """ sessio = connection.session.session() if sessio.transaction.is_active: try: xid = sessio.query(func.txid_current()).first() logger.info("Transaction id: %s" % xid) except: pass logger.debug("Rollback due to error") sessio.rollback()