Bug #103355 Connector / Python not compatible with Django 3.2 for lack of mysql_server_data
Submitted: 18 Apr 2021 14:11 Modified: 27 Jun 2021 9:41
Reporter: Jacob Walls Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S2 (Serious)
Version:8.0.23 OS:MacOS
Assigned to: CPU Architecture:Any
Tags: connector, Django, python

[18 Apr 2021 14:11] Jacob Walls
Description:
mysql-connector-python is not compatible with Django 3.2

This Django commit created the cached property `mysql_server_data`, which mysql-connector-python does not have:
https://github.com/django/django/commit/e37f80961884c686802a5822ce09f24d8a27920f#diff-dabf...

When this failure occurs from running `python3 manage.py runserver`:

  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/db/backends/mysql/features.py", line 150, in is_sql_auto_is_null_enabled
    return self.connection.mysql_server_data['sql_auto_is_null']
AttributeError: 'DatabaseWrapper' object has no attribute 'mysql_server_data'

It is actually masked because of the earlier call to `sql_mode`, and a cryptic AttributeError is raised instead from DatabaseWrapper.__getattr__():

  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/db/backends/mysql/validation.py", line 15, in _check_sql_mode
    if not (self.connection.sql_mode & {'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES'}):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mysql/connector/django/base.py", line 291, in __getattr__
    raise AttributeError
AttributeError

I dug to find the original problem by commenting out DatabaseWrapper.__getattr()

How to repeat:
Install Django 3.2
Install mysql-connector-python 8.0.23

Django settings.py
DATABASES = {
    'default': {
        'ENGINE': 'mysql.connector.django',
        'NAME': '<user_data>',
        'USER': 'root',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}

python3 manage.py runserver

Suggested fix:
Implement mysql_server_data().

Thanks for your work. :-)
[19 Apr 2021 8:37] MySQL Verification Team
Hello Alastair Mooney,

Thank you for the report and feedback.

regards,
Umesh
[22 Apr 2021 9:41] Nuno Mariz
Posted by developer:
 
Fixed by BUG#32435181
[27 Jun 2021 9:41] MySQL Verification Team
Fixed as of the upcoming MySQL Connector/Python 8.0.24 release, and here's
the proposed changelog entry from the documentation team:

Added Django 3.2 support while preserving compatibility with Django 2.2,
3.0, and 3.1.

Thank you for the bug report.