Bug #72542 Problems with mysql-connector-python with Django 1.7 and Python 3.3
Submitted: 6 May 2014 0:39 Modified: 4 Nov 2014 8:16
Reporter: Richard Esplin Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S3 (Non-critical)
Version:1.1.6 1.2.1 OS:Linux
Assigned to: Geert Vanderkelen CPU Architecture:Any
Tags: Django

[6 May 2014 0:39] Richard Esplin
Description:
I am trying to use the MySQL Python Connector with Python 3.3 and Django 1.7. Django 1.7 replaces syncdb with a migrate command.

When I run the command to populate my database, I get the following:

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/richard/proj/venv/django-1.7/django/core/management/__init__.py", line 427, in execute_from_command_line
    utility.execute()
  File "/home/richard/proj/venv/django-1.7/django/core/management/__init__.py", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/richard/proj/venv/django-1.7/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/richard/proj/venv/django-1.7/django/core/management/base.py", line 337, in execute
    output = self.handle(*args, **options)
  File "/home/richard/proj/venv/django-1.7/django/core/management/commands/migrate.py", line 63, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/home/richard/proj/venv/django-1.7/django/db/migrations/executor.py", line 14, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/home/richard/proj/venv/django-1.7/django/db/migrations/loader.py", line 45, in __init__
    self.build_graph()
  File "/home/richard/proj/venv/django-1.7/django/db/migrations/loader.py", line 145, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/home/richard/proj/venv/django-1.7/django/db/migrations/recorder.py", line 57, in applied_migrations
    self.ensure_schema()
  File "/home/richard/proj/venv/django-1.7/django/db/migrations/recorder.py", line 50, in ensure_schema
    with self.connection.schema_editor() as editor:
  File "/home/richard/proj/venv/django-1.7/django/db/backends/__init__.py", line 556, in schema_editor
    raise NotImplementedError('subclasses of BaseDatabaseWrapper may require a schema_editor() method')
NotImplementedError: subclasses of BaseDatabaseWrapper may require a schema_editor() method

I am using the latest Django 1.7 beta branch from GitHub. I tried the stable 1.1.6 connector and the development 1.2.1 connector.

It looks like someone else is having the same issue, so I don't think it is just me:

https://groups.google.com/forum/#!searchin/django-users/django$201.7$20mysql/django-users/...

How to repeat:
Install Python 3.3.

Create a venv.

Activate the venv.

Install pip into the venv.

Install Django 1.7:
pip3 install -e  git://github.com/django/django.git@stable/1.7.x#egg=django

Install mysql-connector-python:
pip3 install --allow-all-external mysql-connector-python

Create a Django project.

Create a database.

Define the databes in settings.py

 DATABASES = {
     'default': {
       'ENGINE': 'mysql.connector.django',
       'NAME': 'alfid',
       'USER': 'alfid',
       'PASSWORD': 'alfid',
       'OPTIONS': {
         'autocommit': True,
       },
     }
 }

./manage.py migrate

Suggested fix:
I think the connector needs to implement additional methods to support the new migration functionality in Django 1.7.
[6 May 2014 5:02] Richard Esplin
I also get the same error if I run syncdb (so long as I turn off DEBUG so that execution will proceed past the deprecation warning).
[8 May 2014 8:18] Geert Vanderkelen
Thank you for the report.
We still need to work on Django 1.7 and make sure we support it in future release of Connector/Python. Note that Django 1.7 is under development; we currently only test Django 1.4, 1.5 and 1.6.

(Setting bug report to S3)
[5 Jun 2014 19:44] John Mitchell
I just want to say that I have replicated this issue exactly...at the current moment, I do not think there is a driver that works with Python 3.3, Django 1.7 and MySQL (5.x, can't remember)
[25 Aug 2014 1:49] Brian May
Any sign of an update on this? Django 1.7 RC3 has been released, and they are getting pretty close to releasing Django 1.7 final. I would like to be able to test my software works with Django 1.7 + Python3 + Mysql before Django 1.7 is released.

Furthermore, this needs to be fixed before Debian/Jessie freezes, or Debian will ship with a version that cannot be used Django 1.7

(yes, I know, an alternative option is that I switch to another database *cough* postgresql *cough* that works out of the box without any dramas)
[25 Aug 2014 1:56] Brian May
Also, in case it is not clear, this breaks both Python2 and Python3. Although with Python2 there is the non-native mysqldb driver that I believe still works.
[2 Sep 2014 23:00] Brian May
Django 1.7 has now been released. 
https://www.djangoproject.com/weblog/2014/sep/02/release-17-final/

Oh, wait, looks like version 1.2.3 fixes this. Maybe Oracle should have closed this bug? Nothing like keeping your user base in the dark.

http://dev.mysql.com/doc/relnotes/connector-python/en/news-1-2-3.html
[4 Nov 2014 8:16] Peeyush Gupta
Fixed in v1.2.3 and v2.0.1.