[DB-SIG] Need help regarding XA Compliant 2PC protocol

Stuart Bishop stuart at stuartbishop.net
Fri Jan 18 14:33:19 CET 2008


James Henstridge wrote:

> The patch I did for psycopg2 should let you perform 2PC, so could be
> used as above whether or not the Oracle adapter you are using supports
> it.

You can also do this right now if you don't mind it being ugly:

con = psycopg.connect('')
[... do stuff ...]
xid = 'xid%f' % random()

cur = con.cursor()
cur.execute('PREPARE TRANSACTION %s', [xid])
try:
    [... commit oracle ...]
except:
    cur.execute('ROLLBACK PREPARED %s', [xid])
else:
    cur.execute('COMMIT PREPARED %s', [xid])


You might be able to do the same trick with Oracle, allowing you to handle
more than 2 Oracle connections safely.

-- 
Stuart Bishop <stuart at stuartbishop.net>
http://www.stuartbishop.net/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://mail.python.org/pipermail/db-sig/attachments/20080118/5d25acfd/attachment.pgp 


More information about the DB-SIG mailing list