From 4abca61b4903e42f9568cc06f3c18ac27a139cf7 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 3 May 2022 08:58:27 -0400 Subject: [PATCH] bypass pyodbc default server version / set charset Further adjustments to the MySQL PyODBC dialect to allow for complete connectivity, which was previously still not working despite fixes in :ticket:`7871`. Fixes: #7966 Change-Id: I549ea9e7b6e722e22d3e25bdb2fe0934603e2454 --- doc/build/changelog/unreleased_14/7966.rst | 7 +++++++ lib/sqlalchemy/dialects/mysql/pyodbc.py | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 doc/build/changelog/unreleased_14/7966.rst diff --git a/doc/build/changelog/unreleased_14/7966.rst b/doc/build/changelog/unreleased_14/7966.rst new file mode 100644 index 0000000000..b07baec453 --- /dev/null +++ b/doc/build/changelog/unreleased_14/7966.rst @@ -0,0 +1,7 @@ +.. change:: + :tags: bug, mysql + :tickets: 7966 + + Further adjustments to the MySQL PyODBC dialect to allow for complete + connectivity, which was previously still not working despite fixes in + :ticket:`7871`. diff --git a/lib/sqlalchemy/dialects/mysql/pyodbc.py b/lib/sqlalchemy/dialects/mysql/pyodbc.py index 28dafc5a01..2d31dfe5fb 100644 --- a/lib/sqlalchemy/dialects/mysql/pyodbc.py +++ b/lib/sqlalchemy/dialects/mysql/pyodbc.py @@ -90,6 +90,9 @@ class MySQLDialect_pyodbc(PyODBCConnector, MySQLDialect): # # If it's decided that issuing that sort of SQL leaves you SOL, then # this can prefer the driver value. + + # set this to None as _fetch_setting attempts to use it (None is OK) + self._connection_charset = None try: value = self._fetch_setting(connection, "character_set_client") if value: @@ -103,6 +106,9 @@ class MySQLDialect_pyodbc(PyODBCConnector, MySQLDialect): ) return "latin1" + def _get_server_version_info(self, connection): + return MySQLDialect._get_server_version_info(self, connection) + def _extract_error_code(self, exception): m = re.compile(r"\((\d+)\)").search(str(exception.args)) c = m.group(1) -- 2.47.2