0

I want to set the mysql database using mysql-connector-python for setting up a web site made with Django using a database backend but I get this error:

django.core.exceptions.ImproperlyConfigured: 'mysql.connector.django' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
    'mysql', 'oracle', 'postgresql', 'sqlite3'

My credentials (name, user, password, host, port) works fine, so the problem isn't here.

DATABASES = {
    'default': {
        'ENGINE':   'mysql.connector.django',
        'NAME':     'library',
        'USER':     'username',
        'PASSWORD': 'password',
        'HOST':     '127.0.0.1',
        'PORT':     '3306',
        'OPTIONS': {
            'autocommit': True,
            'use_pure': True,
        },
    }
}

I'm using python 3.8.5 and mysql-connector-python 8.0.21 and I understand that mysql-connector-python, starting from version 8.0.13, has a bug, which makes it impossible to use with Django and to avoid the bug I added ‘use_pure’: True in database options. But it doesn't work.

I found this question but it doesn't say anything about using ‘use_pure’: True.

If the mysql-connector-python isn't compatible with python 3, what can I use instead? (I can't wait for the support release).

Cătălina Sîrbu
  • 1,183
  • 8
  • 26
  • Is there a reason you are not using `'ENGINE': 'django.db.backends.mysql'` like the [Django docs suggest](https://docs.djangoproject.com/en/3.1/ref/settings/#engine) ? – Ralf Sep 24 '20 at 12:26
  • @Ralf, I tried this but it works only local. If I try to push it to my webpage and use it remotely I receive error messages. – Cătălina Sîrbu Sep 24 '20 at 12:42
  • Hi. Support for Django 3.0 and 3.1 (with Python 3) will be released soon with a new version of Connector/Python. – Nuno Mariz Oct 06 '20 at 11:18

1 Answers1

0

you do not have the option to use mysql connector, you have to install mysql-client from https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient and try installing all the wheels incase you get errors, while installing using pip install

Ahmad Waqar
  • 446
  • 3
  • 7