0

I have tried using

  1. pymysql
  2. mysql-client
  3. mysql-connector-pyhton

and various other ways stated in this question but still I am not able to use MySql as my database.

Whenever I try to do run it shows below error message.

raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'

I have tried these two Database configuration in my setting.py file

Setting 1: This works with python 2.7

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'user_db',
        'USER': 'ecom',
        'PASSWORD': 'ecom@123',
        'HOST': 'localhost',   # Or an IP Address that your DB is hosted on
        'PORT': '',
    }
}

error message :

`raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'`

Setting 2: as suggested in this question's answer

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

error message :

Try using 'django.db.backends.XXX', where XXX is one of:
    'mysql', 'oracle', 'postgresql', 'sqlite3'
Error was: No module named 'mysql'

Still I am not able to use mysql as backend can anyone please let me know what I am doing wrong or is it even possible with python 3.4.3?

I would be really thankful for your help and guidance.

Community
  • 1
  • 1
Anurag Sinha
  • 187
  • 4
  • 15

0 Answers0