serializable transactions

10 views
Skip to first unread message

Sol

unread,
Oct 15, 2006, 8:22:50 AM10/15/06
to sqlal...@googlegroups.com
Hello,
how would I use serializable transactions with SA and Postgres? Is there
something around that i missed?

--
Cheers, Sol.

Michael Bayer

unread,
Oct 15, 2006, 5:18:17 PM10/15/06
to sqlal...@googlegroups.com
I cant find any official docs for psycopg2 on this, except the
impression from some various mailing list posts that postgres is in
"serializable" mode by default, and also if you want to change the
isolation mode you use connection.set_transaction_isolation(<some
number>). also i dont know what the mapping of numbers to isolation
modes is (might be on the postgres site).

anyway, SA gives you access to the connection like this:

conn = engine.connect()
conn.connection.set_transaction_isolation(1)
trans = conn.begin()

.etc.

you could also set it on all connections globally using a connection
function:

def connect():
c = psycopg2.connect(<args>)
c.set_transaction_isolation(1)
return c

e = create_engine('postgres://', creator=connect)

Reply all
Reply to author
Forward
0 new messages