From: Mike Bayer Date: Tue, 3 May 2022 12:58:27 +0000 (-0400) Subject: bypass pyodbc default server version / set charset X-Git-Tag: rel_1_4_37~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17f33b7d45af0f310db34cfe2c629f3d26dd0796;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git 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 (cherry picked from commit 4abca61b4903e42f9568cc06f3c18ac27a139cf7) --- 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 aa2190bf46..bfa61f6480 100644 --- a/lib/sqlalchemy/dialects/mysql/pyodbc.py +++ b/lib/sqlalchemy/dialects/mysql/pyodbc.py @@ -88,6 +88,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: @@ -101,6 +104,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)