[Sqlalchemy-tickets] Issue #3296: raise if isolation_level execution option is used when a Transact
Brought to you by:
zzzeek
|
From: Mike B. <iss...@bi...> - 2015-01-20 17:27:39
|
New issue 3296: raise if isolation_level execution option is used when a Transaction is present; warning in 0.9 https://bitbucket.org/zzzeek/sqlalchemy/issue/3296/raise-if-isolation_level-execution-option Mike Bayer: isolation level settings typically do not work until the next transaction, and at least in the case of Psycopg2 are destructive. For this reason, the MySQL dialect already implements a COMMIT, and psycopg2 actually *resets* the transaction when you change the level: ``` #!python >>> import psycopg2 >>> conn = psycopg2.connect(user='scott', dbname='test', password='tiger', host='localhost') >>> cursor = conn.cursor() >>> cursor.execute("create table foo (id integer)") >>> cursor.execute("insert into foo (id) values (1)") >>> cursor.close() >>> from psycopg2 import extensions >>> conn.set_isolation_level(extensions.ISOLATION_LEVEL_SERIALIZABLE) >>> cursor = conn.cursor() >>> cursor.execute("select * from foo") Traceback (most recent call last): File "<stdin>", line 1, in <module> psycopg2.ProgrammingError: relation "foo" does not exist LINE 1: select * from foo ^ ``` huge warning is needed and definitely an exception in 1.0. |