Then, in my case, I will have to use an alternative method where my code has control of the transaction. Thank you for the speedy reply.
On Monday, December 5, 2016 at 11:15:12 AM UTC-6, Mike Bayer wrote: > > > > On 12/05/2016 11:10 AM, Corwin Tanner wrote: > > I need to be able to execute some code upon the successful commit of a > > transaction. In this instance, I do not control the transaction and will > > not be the one calling commit. I tried listening to the commit event on > > the Connection object, but this does not give the kind of guarantees I > > need as a transaction can be rolled back after my handler is called. > > > > I know that there is a post_commit event on the ORM. Is there any way to > > replicate this in Core? > > The commit event on Connection occurs before the actual transaction > commit as a means of injecting behavior where it normally would not be > available. The transaction commit is guaranteed to be called after this > hook, however it is not guaranteed to succeed. A failure at this level > can be intercepted using the handle_error event, and a rollback() can > also be intercepted. > > At the core level, the plain Connection does not feature the same > structural overhead as that of the ORM Session object and the > transaction.commit() call is the public facing API, so there is no > "after commit" hook, as immediately "after commit" control is returned > to the calling code without anything else happening. So in this case > the framework you are tying into which calls connection.commit() would > be responsible for providing an after commit hook. > > > > > > > -- > > SQLAlchemy - > > The Python SQL Toolkit and Object Relational Mapper > > > > http://www.sqlalchemy.org/ > > > > To post example code, please provide an MCVE: Minimal, Complete, and > > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > > description. > > --- > > You received this message because you are subscribed to the Google > > Groups "sqlalchemy" group. > > To unsubscribe from this group and stop receiving emails from it, send > > an email to sqlalchemy+...@googlegroups.com <javascript:> > > <mailto:sqlalchemy+unsubscr...@googlegroups.com <javascript:>>. > > To post to this group, send email to sqlal...@googlegroups.com > <javascript:> > > <mailto:sqlal...@googlegroups.com <javascript:>>. > > Visit this group at https://groups.google.com/group/sqlalchemy. > > For more options, visit https://groups.google.com/d/optout. > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.