From: mike bayer Date: Sun, 16 Jun 2013 02:52:00 +0000 (-0700) Subject: Merge pull request #7 from malor/psycopg2_execution_options X-Git-Tag: rel_0_8_2~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a3a446d02b2155001b08af3f0e6d08fe3dc809b;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Merge pull request #7 from malor/psycopg2_execution_options Add AUTOCOMMIT isolation level support for psycopg2 --- diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py index c796c99c73..2d475ccda0 100644 --- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py +++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py @@ -351,6 +351,7 @@ class PGDialect_psycopg2(PGDialect): def _isolation_lookup(self): extensions = __import__('psycopg2.extensions').extensions return { + 'AUTOCOMMIT': extensions.ISOLATION_LEVEL_AUTOCOMMIT, 'READ COMMITTED': extensions.ISOLATION_LEVEL_READ_COMMITTED, 'READ UNCOMMITTED': extensions.ISOLATION_LEVEL_READ_UNCOMMITTED, 'REPEATABLE READ': extensions.ISOLATION_LEVEL_REPEATABLE_READ, diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py index a8003e9736..43c4719190 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -1889,6 +1889,16 @@ class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): c = e.connect() eq_(c.connection.connection.encoding, test_encoding) + @testing.only_on('postgresql+psycopg2', 'psycopg2-specific feature') + @engines.close_open_connections + def test_autocommit_isolation_level(self): + extensions = __import__('psycopg2.extensions').extensions + + c = testing.db.connect() + c = c.execution_options(isolation_level='AUTOCOMMIT') + eq_(c.connection.connection.isolation_level, + extensions.ISOLATION_LEVEL_AUTOCOMMIT) + @testing.fails_on('+zxjdbc', "Can't infer the SQL type to use for an instance " "of org.python.core.PyObjectDerived.")