On Mon, 2010-10-25 at 11:53 +0200, Daniele Varrazzo wrote: > Io per conto mio ho provato: > > import psycopg2 > > def test(dsn): > """test if a connection created in an exception handler goes > autocommit""" > cnn = psycopg2.connect(dsn) > cur = cnn.cursor() > > cur.execute("""drop table if exists test;""") > cur.execute("""create table test (data int primary key); > insert > into test values (1);""") > cnn.commit() > > # make an error > try: > cur.execute("""insert into test values (1)""") > except psycopg2.IntegrityError: > # connection created in the handler > cnn2 = psycopg2.connect(dsn) > cur2 = cnn2.cursor() > cur2.execute("""insert into test values (2)""") > > # was cnn2 autocommit? > cnn3 = psycopg2.connect(dsn) > cur3 = cnn3.cursor() > cur3.execute("select count(*) from test where data = 2") > n = cur3.fetchone()[0] > > assert n == 0, "connection in exception handler autocommit" > > # double check > cnn2.commit() > cur3.execute("select count(*) from test where data = 2") > n = cur3.fetchone()[0] > assert n == 1 > > print "ok" > > test("dbname=test") > > Ma questo test, nelle mie condizioni passa. Io ho sottomano solo una > versione di sviluppo di psycopg: posso provare più tardi con quella > che usi > tu, ma se riesci a creare la condizione che fa fallire l'assert col > tuo > setup allora possiamo dire che c'è un bug. Altrimenti non si sa :)
Testato, passa anche da me nel mio database. Ma ci voglio capire qualcosa di più.... Ciao intanto. _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python