0

I just created a Python/Django project with a MySQL database that I am trying to host on Heroku. I added a ClearDB database to my Heroku project, but when I try to migrate my database, it gives me this error:

DatabaseWrapper.display_name() takes 0 positional arguments but 1 was given

I get the gist of this error, but unfortunately I can't seem to be able to trace the problem back to its source to fix it.

Here is my database configuration in my settings.py file:

DATABASES = {
    'default': {
        'ENGINE': 'mysql.connector.django',
        'NAME': os.environ.get('DB_NAME'),
        'USER': os.environ.get('DB_USER'),
        'PASSWORD': os.environ.get('DB_PASS'),
        'HOST': os.environ.get('DB_HOST'),
        'PORT': '3306',
        'OPTIONS': {
            "use_pure": True
        }
    }
}

And, here is my requirements file:

amqp==5.1.1
asgiref==3.5.2
async-timeout==4.0.2
billiard==3.6.4.0
celery==5.2.7
charset-normalizer==3.0.1
click==8.1.3
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.2.0
colorama==0.4.6
dj-database-url==2.0.0
Django==4.1.3
django-celery-results==2.4.0
django-jsonfield==1.4.1
django-mathfilters==1.0.0
djangorestframework==3.14.0
jsonfield==3.1.0
kombu==5.2.4
mysql==0.0.3
mysql-connector-python==8.0.33
mysqlclient==2.1.1
numpy==1.23.4
pathlib==1.0.1
pdf2image==1.16.2
Pillow==9.3.0
prompt-toolkit==3.0.36
protobuf==3.20.3
PyMySQL==1.0.3
pypdf==3.3.0
PyPDF2==3.0.1
python-dotenv==1.0.0
pytz==2022.7.1
redis==4.5.0
reportlab==3.6.12
simplejson==3.18.1
six==1.16.0
sqlparse==0.4.3
typing_extensions==4.5.0
tzdata==2022.6
urllib3==1.26.14
vine==5.0.0
wcwidth==0.2.6

I found another post regarding this on reddit, and it told me:

are you using mysql-connector-python? if so, downgrade to 8.0.29, there's a bug in 8.0.30 and later that breaks compatibility with the django app.

but unfortunately this will not help as I am using mysql.connector.django.

How can I fix this?

1 Answers1

0

I have the same issue like that. and i put this to the bottom of my setting.py
'OPTIONS': {'init_command': "SET sql_mode='STRICT_TRANS_TABLES'" ,"use_pure": True},

In this case :

   DATABASES = {
            'default': {
                'ENGINE': 'mysql.connector.django',
                'NAME': os.environ.get('DB_NAME'),
                'USER': os.environ.get('DB_USER'),
                'PASSWORD': os.environ.get('DB_PASS'),
                'HOST': os.environ.get('DB_HOST'),
                'PORT': '3306',
                'OPTIONS': {'init_command': "SET sql_mode='STRICT_TRANS_TABLES'" ,"use_pure": True},
                }
            }
        }