MySQL Connector for Python 3

3

I'm doing a project with Django and Python 3 but I can not find the appropriate MySQL connector. django.db.backends.mysql works, but only for Python 2, and I wanted to avoid using that version. In the terminal when I type import django.db.backends.mysql it imports without any error, but when I go to run on the server with the command python3 manage.py runserver the error appears:

  

File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/backends/mysql/base.py", line 18, in       raise ImproperlyConfigured ("Error loading MySQLdb module:% s"% e)   django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'

Can you solve this? Do Django projects have any development constraints using Python 3?

Currently the development environment is in an OS X Yosemite.

Thank you!

    
asked by anonymous 12.03.2015 / 20:37

1 answer

3

Apparently this is a classic problem of this particular plugin.

Using pip , execute the following:

pip install --allow-all-external mysql-connector-python

Set your settings.py file to the following:

DATABASES = {
    'default': {
        'ENGINE': 'mysql.connector.django',
        'NAME': 'mydb',
        'USER': 'myuser',
        'PASSWORD': 'mypassword',
    }
}

I got the answer from here .

    
12.03.2015 / 20:48