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!

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.