Re: [sqlalchemy] tying multiple sessions together with one transaction

2014-03-07 Thread Laurence Rowe
IIRC, the implementation of the two phase commit basically has everyone flush on Phase1, then report back as a vote. If there are any negative votes, the transaction manager instructs everyone to fail and rollback as Phase2. If you had a flush that caused an integrity error before

Re: [sqlalchemy] tying multiple sessions together with one transaction

2014-03-03 Thread Chris Withers
Hi Simon, On 26/02/2014 13:18, Simon King wrote: I don't know exactly what your needs are, but here's the example from the docs: engine1 = create_engine('postgresql://db1') engine2 = create_engine('postgresql://db2') Session = sessionmaker(twophase=True) # bind User

Re: [sqlalchemy] tying multiple sessions together with one transaction

2014-03-03 Thread Simon King
On Mon, Mar 3, 2014 at 7:55 AM, Chris Withers ch...@simplistix.co.uk wrote: Hi Simon, On 26/02/2014 13:18, Simon King wrote: I don't know exactly what your needs are, but here's the example from the docs: engine1 = create_engine('postgresql://db1') engine2 =

Re: [sqlalchemy] tying multiple sessions together with one transaction

2014-03-03 Thread Jonathan Vanasco
On Monday, March 3, 2014 5:26:29 AM UTC-5, Simon King wrote: Partially innocent question: If one of the flushes you describe above fails (say with an integrity error), then the transactions would be left in need of a rollback on all engines and definitely no data would be

Re: [sqlalchemy] tying multiple sessions together with one transaction

2014-03-03 Thread Chris Withers
Hi Jonathan, On 03/03/2014 17:22, Jonathan Vanasco wrote: Yep. You can look at the internals of the 'Transaction' package and cross reference to the zope.sqlachemy to see exactly how it works. Sorry, not sure if I'm following you, but I'm talking about Simon's suggestion only to use a

Re: [sqlalchemy] tying multiple sessions together with one transaction

2014-02-26 Thread Chris Withers
Hi Simon, The problem is that I want to use multiple sessions, I think. How would I have connections to multiple databases with differing schemas using a single Session? cheers, Chris On 25/02/2014 18:14, Simon King wrote: I've never used two-phase commit, but can you get away with just a

Re: [sqlalchemy] tying multiple sessions together with one transaction

2014-02-26 Thread Simon King
I don't know exactly what your needs are, but here's the example from the docs: engine1 = create_engine('postgresql://db1') engine2 = create_engine('postgresql://db2') Session = sessionmaker(twophase=True) # bind User operations to engine 1, Account operations to engine 2

Re: [sqlalchemy] tying multiple sessions together with one transaction

2014-02-25 Thread Chris Withers
No takers? :'( On 19/02/2014 18:43, Chris Withers wrote: Hi All, My other usual question now ;-) I have multiple databases that I'm connecting to from my application. I need to commit or rollback a single transaction across all of them. So, two phase commit, right? Okay, but how do I tie

Re: [sqlalchemy] tying multiple sessions together with one transaction

2014-02-25 Thread Simon King
I've never used two-phase commit, but can you get away with just a single session, like the example at: http://docs.sqlalchemy.org/en/rel_0_9/orm/session.html#enabling-two-phase-commit Simon On Tue, Feb 25, 2014 at 6:07 PM, Chris Withers ch...@simplistix.co.uk wrote: No takers? :'( On

Re: [sqlalchemy] tying multiple sessions together with one transaction

2014-02-25 Thread Jonathan Vanasco
If you do need to use zope.transaction ( and not just the SqlAlchemy option that Simon posted ) , there already exists Zope/SqlAlchemy integration -- https://pypi.python.org/pypi/zope.sqlalchemy -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To

[sqlalchemy] tying multiple sessions together with one transaction

2014-02-19 Thread Chris Withers
Hi All, My other usual question now ;-) I have multiple databases that I'm connecting to from my application. I need to commit or rollback a single transaction across all of them. So, two phase commit, right? Okay, but how do I tie the sessions together? What and how do I call commit? Is