#29678: inspectdb fails on MySQL 8 with " 'utf8' is currently an alias for the
character set UTF8MB3"
-------------------------------------+-------------------------------------
Reporter: SuilAmhain | Owner: nobody
Type: Bug | Status: closed
Component: Core (Management | Version: 2.1
commands) | Resolution:
Severity: Normal | worksforme
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by SuilAmhain):
I have found a workaround of sorts.
For the record:
- mysql-connector-python=8.0.12
- I have just moved the MySQL instance from 8.0.11 to 8.0.12
- django 2.1
I have tried various settings passed to the database via {{{settings.py}}}
but getting nowhere with them, for example:
{{{
DATABASES = {
'default': {
'ENGINE': 'mysql.connector.django',
# 'ENGINE': 'django.db.backends.mysql',
'NAME': '<value>',
'USER': '<value>',
'PASSWORD': '<value>',
'HOST': '<value>',
'CHARSET': 'utf8mb4',
'COLLATION': 'utf8mb4_unicode_ci',
'PORT': '3309',
'OPTIONS': {'sql_mode': 'TRADITIONAL', 'use_pure': True,
'use_unicode': True, 'charset': 'utf8mb4',
'collation':
'utf8mb4_general_ci','get_warnings':False},
}
}}}
MySQL connector docs state that {{{raise_on_warnings}}} defaults to
{{{False}}}. It is however getting set to true somewhere in the code.
- https://dev.mysql.com/doc/connector-python/en/connector-python-api-
mysqlconnection-raise-on-warnings.html
In {{{site-packages -> mysql -> connector -> cursor.py}}} I changed the
last few lines of the {{{execute}}} function to:
{{{
if multi:
self._executed_list = []
return
self._execute_iter(self._connection.cmd_query_iter(stmt))
exlcude_schema=b'information_schema' # New COS Workaround
if exlcude_schema in stmt: # New COS Workaround
print(self._connection.get_warnings) # New COS Workaround
self._connection.get_warnings = False # New COS Workaround
try:
self._handle_result(self._connection.cmd_query(stmt))
except errors.InterfaceError:
if self._connection._have_next_result: # pylint:
disable=W0212
raise errors.InterfaceError(
"Use multi=True when executing multiple statements")
raise
return None
}}}
It is not very elegant, but I am rushing for a college deadline and well
time is ticking.
--
Ticket URL: <https://code.djangoproject.com/ticket/29678#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.2b573cbe5e3d8a84ec9fba0301143dc9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.