]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Merge pull request #7 from malor/psycopg2_execution_options
authormike bayer <mike_mp@zzzcomputing.com>
Sun, 16 Jun 2013 02:52:00 +0000 (19:52 -0700)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 16 Jun 2013 02:58:46 +0000 (22:58 -0400)
Add AUTOCOMMIT isolation level support for psycopg2

lib/sqlalchemy/dialects/postgresql/psycopg2.py
test/dialect/test_postgresql.py

index c796c99c73ce1a39909f475f7cc7592dbcfb1248..2d475ccda066f6bb2c6f75cfe1b206470f1a9df3 100644 (file)
@@ -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,
index a8003e9736322ed10b4a625e57e628c32c8e43a4..43c4719190bc3e3587e53ed8d7758a7d45aeae49 100644 (file)
@@ -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.")