--- /dev/null
+.. change::
+ :tags: bug, mysql
+ :tickets: 5239
+
+ 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.
+
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()
):
engine.connect()
+ def test_no_default_isolation_level(self):
+ from sqlalchemy.testing import mock
+
+ engine = engines.testing_engine()
+
+ real_isolation_level = testing.db.dialect.get_isolation_level
+
+ def fake_isolation_level(connection):
+ connection = mock.Mock(
+ cursor=mock.Mock(
+ return_value=mock.Mock(
+ fetchone=mock.Mock(return_value=None)
+ )
+ )
+ )
+ return real_isolation_level(connection)
+
+ with mock.patch.object(
+ engine.dialect, "get_isolation_level", fake_isolation_level
+ ):
+ with expect_warnings(
+ "Could not retrieve transaction isolation level for MySQL "
+ "connection."
+ ):
+ engine.connect()
+
def test_autocommit_isolation_level(self):
c = testing.db.connect().execution_options(
isolation_level="AUTOCOMMIT"