From 9e028e6799065327562ace2415185706b0d9a932 Mon Sep 17 00:00:00 2001 From: hirenkumar-n-dholariya Date: Fri, 10 Apr 2026 18:17:41 -0400 Subject: [PATCH 1/2] fix: explicitly set charset=utf8mb4 to fix MySQL connection error (#2583) When using mysql-connector-python >= 8.0.30, the connector internally remaps charset 'utf8' to 'utf8mb4'. Since no charset was explicitly set in the connect() call, this remapping triggered automatically and caused the error on MySQL servers < 5.5.3: "Character set 'utf8' unsupported" Fix: explicitly pass charset="utf8mb4" and use_unicode=True to the mysql.connector.connect() call. This bypasses the internal remapping logic entirely and works correctly across all supported MySQL versions. utf8mb4 is the recommended charset since MySQL 5.5.3 and is fully backwards compatible with utf8 data. Fixes #2583 --- soda/mysql/soda/data_sources/mysql_data_source.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/soda/mysql/soda/data_sources/mysql_data_source.py b/soda/mysql/soda/data_sources/mysql_data_source.py index beda97e7f..8f4c46912 100644 --- a/soda/mysql/soda/data_sources/mysql_data_source.py +++ b/soda/mysql/soda/data_sources/mysql_data_source.py @@ -78,8 +78,9 @@ def __init__(self, logs: Logs, data_source_name: str, data_source_properties: di def connect(self): try: self.connection = mysql.connector.connect( - user=self.username, password=self.password, host=self.host, port=self.port, database=self.database + user=self.username, password=self.password, host=self.host, port=self.port, database=self.database, charset="utf8mb4", use_unicode=True ) + return self.connection except Exception as e: raise DataSourceConnectionError(self.TYPE, e) From 2d025d5284b6e99564ab67ab2df1c55f7162601a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 22:19:47 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- soda/mysql/soda/data_sources/mysql_data_source.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/soda/mysql/soda/data_sources/mysql_data_source.py b/soda/mysql/soda/data_sources/mysql_data_source.py index 8f4c46912..fe45c1dfa 100644 --- a/soda/mysql/soda/data_sources/mysql_data_source.py +++ b/soda/mysql/soda/data_sources/mysql_data_source.py @@ -78,7 +78,13 @@ def __init__(self, logs: Logs, data_source_name: str, data_source_properties: di def connect(self): try: self.connection = mysql.connector.connect( - user=self.username, password=self.password, host=self.host, port=self.port, database=self.database, charset="utf8mb4", use_unicode=True + user=self.username, + password=self.password, + host=self.host, + port=self.port, + database=self.database, + charset="utf8mb4", + use_unicode=True, ) return self.connection