diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-06-04 19:53:24 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-06-04 19:53:24 -0400 |
commit | 8c09969d44c7d66634c3a392f17383ebfacb2881 (patch) | |
tree | 6512d34456b5b2efe86a21bfb4a3a0c754115f48 | |
parent | 5cac2468b6ef9e7ab4c0f3400477b697cd2d4ec6 (diff) | |
download | sqlalchemy-8c09969d44c7d66634c3a392f17383ebfacb2881.tar.gz |
- Accept None from SQLite cursor.fetchone() when
"PRAGMA read_uncommitted" is called to determine
current isolation mode at connect time and
default to SERIALIZABLE; this to support SQLite
versions pre-3.3.0 that did not have this
feature. [ticket:2173]
-rw-r--r-- | CHANGES | 8 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/sqlite/base.py | 12 |
2 files changed, 19 insertions, 1 deletions
@@ -37,6 +37,14 @@ CHANGES and are redundant: reflecttable(), create(), drop(), text(), engine.func +- sqlite + - Accept None from cursor.fetchone() when + "PRAGMA read_uncommitted" is called to determine + current isolation mode at connect time and + default to SERIALIZABLE; this to support SQLite + versions pre-3.3.0 that did not have this + feature. [ticket:2173] + - mysql - Unit tests pass 100% on MySQL installed on windows. diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py index 4ab509318..331ab92d0 100644 --- a/lib/sqlalchemy/dialects/sqlite/base.py +++ b/lib/sqlalchemy/dialects/sqlite/base.py @@ -505,7 +505,17 @@ class SQLiteDialect(default.DefaultDialect): def get_isolation_level(self, connection): cursor = connection.cursor() cursor.execute('PRAGMA read_uncommitted') - value = cursor.fetchone()[0] + res = cursor.fetchone() + if res: + value = res[0] + else: + # http://www.sqlite.org/changes.html#version_3_3_3 + # "Optional READ UNCOMMITTED isolation (instead of the + # default isolation level of SERIALIZABLE) and + # table level locking when database connections + # share a common cache."" + # pre-SQLite 3.3.0 default to 0 + value = 0 cursor.close() if value == 0: return "SERIALIZABLE" |