summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-04-07 19:21:01 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-04-07 19:21:01 -0400
commit978755e851e505e2715e71efcb51b0904ded9f80 (patch)
treea5b6202c2f94bd98ce8c1d9f2e79f115b6ffadb8 /lib/sqlalchemy/dialects
parent5150ef4ed166042b4a1f4a77b5a0af609b5fc660 (diff)
downloadsqlalchemy-978755e851e505e2715e71efcb51b0904ded9f80.tar.gz
Gracefully skip isolation level if no row returned
Fixed issue in MySQL dialect when connecting to a psuedo-MySQL database such as that provided by ProxySQL, the up front check for isolation level when it returns no row will not prevent the dialect from continuing to connect. A warning is emitted that the isolation level could not be detected. Fixes: #5239 Change-Id: I4a240386a0d38bd90733819495ce50e37fe2234c
Diffstat (limited to 'lib/sqlalchemy/dialects')
-rw-r--r--lib/sqlalchemy/dialects/mysql/base.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index 26d751faa..54a13b550 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -2297,7 +2297,14 @@ class MySQLDialect(default.DefaultDialect):
cursor.execute("SELECT @@transaction_isolation")
else:
cursor.execute("SELECT @@tx_isolation")
- val = cursor.fetchone()[0]
+ row = cursor.fetchone()
+ if row is None:
+ util.warn(
+ "Could not retrieve transaction isolation level for MySQL "
+ "connection."
+ )
+ raise NotImplementedError()
+ val = row[0]
cursor.close()
if util.py3k and isinstance(val, bytes):
val = val.decode()