Django error when using mysql-connector-python

341 views Asked by At

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).

1

There are 1 answers

0
Ahmad Waqar On

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