Bug #96638 mysql connector-python-connectargs needs update for the collation argument.
Submitted: 23 Aug 2019 12:59 Modified: 9 Sep 2019 20:44
Reporter: lalit Choudhary Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Documentation Severity:S3 (Non-critical)
Version:8.0.17 OS:Any
Assigned to: CPU Architecture:Any

[23 Aug 2019 12:59] lalit Choudhary
Description:

https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html

Above document link about mysql connector-python-connectargs need update for the collation argument. 

collation	default-> utf8_general_ci	 Which MySQL collation to use.

This is true for old mysql python connectors
 >>> mysql.connector.__version__
'2.1.6'

>>> mysql.connector.__version__
'8.0.17'
For new version mysql python connectors 8.0 version default is collation is utf8mb4_general_ci

How to repeat:
------------
test .py 
-----------

import mysql.connector
from mysql.connector import Error
try:
    connection = mysql.connector.connect(host='192.168.0.128',
                                         port='5726',
                                         database='test',
                                         user='msandbox',
                                         password='msandbox'
                                         )

    if connection.is_connected():
        db_Info = connection.get_server_info()
        print("Connected to MySQL Server version ", db_Info)
        cursor = connection.cursor()
        cursor.execute("select @@collation_connection;")
        record = cursor.fetchone()
        print("Your connection charset_collation: ", record)
except Error as e:
    print("Error while connecting to MySQL", e)
finally:
    if (connection.is_connected()):
        cursor.close()
        connection.close()
        print("MySQL connection is closed")

# python test1.py 
('Connected to MySQL Server version ', u'8.0.15-6')
('Your connection charset_collation: ', (u'utf8mb4_general_ci',))
MySQL connection is closed

# python test1.py 
('Connected to MySQL Server version ', u'5.7.26-29-debug-valgrind-asan')
('Your connection charset_collation: ', (u'utf8mb4_general_ci',))
MySQL connection is closed
[26 Aug 2019 6:41] MySQL Verification Team
Hello Lalit,

Thank you for the report and test case.

regards,
Umesh
[9 Sep 2019 20:44] Philip Olson
Posted by developer:
 
The C/Py 8.x default values are generated from the latest MySQL Server 8.0 defaults, so this is what happened here. 

This is now documented, thank you for the bug report!