Bug #108744 mysql-connector-python: server version is a global "constant"
Submitted: 11 Oct 2022 15:11 Modified: 18 Nov 2022 9:59
Reporter: Anye Li Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / Python Severity:S3 (Non-critical)
Version:8.0.31 OS:Any
Assigned to: CPU Architecture:Any

[11 Oct 2022 15:11] Anye Li
Description:
Connecting to a MySQL server running version 5.7 causes global changes to mysql.connector.constants.CharacterSet that causes "Character set 'utf8' unsupported" errors later if you try to connect to a server running version 8.0.

I reported this in my comment to https://bugs.mysql.com/bug.php?id=108346 but it would appear that closed bugs are not monitored.

I realize you are not interested in supporting old versions, but in this case the version of the server is not under my control - merely connecting to an older server should not cause my client code to break.

How to repeat:
Use Connector/Python to connect to a server running version 5.7.  Then, in the same application, connect to another server running 8.0.
[14 Oct 2022 10:09] MySQL Verification Team
Hello Anye Li,

Thank you for the bug report.
Could you please provide a code snippet or more detailed information to reproduce this issue at our end?

Regards,
Ashwini Patil
[14 Oct 2022 16:51] Anye Li
Assuming you have one server running 5.7 and another running 8.0 (e.g. with docker; setting this up is beyond the scope of this report), then something like this will trigger the bug:

import mysql.connector

mysql.connector.connect(**mysql80_args,use_pure=True) # works fine
mysql.connector.connect(**mysql57_args,charset='latin1',use_pure=True) # without the charset arg I get the unsupported charset 'utf8' bug
mysql.connector.connect(**mysql80_args,use_pure=True) # triggers the unsupported charset 'utf8' bug
[18 Nov 2022 9:59] MySQL Verification Team
Hello Anye Li,

Thank you for the details.
I tried to reproduce your issue on windows 10 with Connector/Python and tried to connect to MySQL Server 5.7 and 8.0 in the same application but I am not seeing any issues at my end.

Regards,
Ashwini Patil