diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2013-06-15 19:52:00 -0700 |
---|---|---|
committer | mike bayer <mike_mp@zzzcomputing.com> | 2013-06-15 19:52:00 -0700 |
commit | 9612e2fbb5b8e49b58c0a93a6cb154f81545f2db (patch) | |
tree | 4495c1a53df35d76880d06565c101ef4f277fb20 | |
parent | b92007da7d9cd7453a2da9f1767e8a988f05acb7 (diff) | |
parent | a1ceae2ed3b3996d5b8a554c201cf668d6d17f27 (diff) | |
download | sqlalchemy-9612e2fbb5b8e49b58c0a93a6cb154f81545f2db.tar.gz |
Merge pull request #7 from malor/psycopg2_execution_options
Add AUTOCOMMIT isolation level support for psycopg2
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/psycopg2.py | 1 | ||||
-rw-r--r-- | test/dialect/test_postgresql.py | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py index fcc1946ff..c7f9f0187 100644 --- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py +++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py @@ -350,6 +350,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 00e5c07ab..d1ba960c4 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -1890,6 +1890,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.") |