8000 BUG#34675508: Character set 'utf8' unsupported in python mysql connec… · mysql/mysql-connector-python@6171c91 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6171c91

Browse files
committed
BUG#34675508: Character set 'utf8' unsupported in python mysql connector when using MariaDB
Connection fails when connecting to a MariaDB server using the MySQL Connector/Python driver for adapter versions 8.0.30 and 8.0.31 due to unsupported charset. This issue is invariant to the type of connection, that's to say, it happens when using a pooled connection or not. The bug happens because the default MySQL character collection, that is 8.0 specific, does not recognize the utf8 charset name. With this patch, the bug is fixed by using the LTS (5.7) MySQL character collection as default instead. The new default will switch to the 8.0 specific character collection when the queried server version is 8.0.X. Change-Id: I5b38bf27887ed25ae1d2d18dcd22637db260ae47
1 parent bff8a18 commit 6171c91

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ v8.0.32
1515
- WL#15036: Support for type hints
1616
- BUG#34710366: Django implementation does not pass unit tests
1717
- BUG#34689812: Fix datetime conversion when using prepared cursors
18+
- BUG#34675508: Character set 'utf8' unsupported in python mysql connector when using MariaDB
1819
- BUG#34556157: Kerberos authorization fails when using SSPI as security interface
1920
- BUG#34499578: MySQLCursor.executemany() fails to correctly identify BULK data loading ops
2021
- BUG#30089671: Fix decoding VARBINARY columns when using a prepared cursor

lib/mysql/connector/constants.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,9 @@ class CharacterSet(_Constants):
679679
name of the used character set or collation.
680680
"""
681681

682-
desc: List[Optional[Tuple[str, str, bool]]] = MYSQL_CHARACTER_SETS # type: ignore[assignment]
683-
mysql_version: Tuple[int, ...] = (8, 0)
682+
# Use LTS character set as default
683+
desc: List[Optional[Tuple[str, str, bool]]] = MYSQL_CHARACTER_SETS_57 # type: ignore[assignment]
684+
mysql_version: Tuple[int, ...] = (5, 7)
684685

685686
# Multi-byte character sets which use 5c (backslash) in characters
686687
slash_charsets: Tuple[int, ...] = (1, 13, 28, 84, 87, 88)
@@ -693,8 +694,8 @@ def set_mysql_version(cls, version: Tuple[int, ...]) -> None:
693694
version (tuple): MySQL version tuple.
694695
"""
695696
cls.mysql_version = version[:2]
696-
if cls.mysql_version == (5, 7):
697-
cls.desc = MYSQL_CHARACTER_SETS_57
697+
if cls.mysql_version == (8, 0):
698+
cls.desc = MYSQL_CHARACTER_SETS
698699

699700
@classmethod
700701
def get_info(cls, setid: int) -> Tuple[str, str]:

0 commit comments

Comments
 (0)
0