I am attempting to change my database settings in my django project from sqlite3 to mysql.
I edited the database object in my settings.py file :
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'Identity',
'USER' : 'root',
'PASSWORD': ''
}
}
I ran django-admin dbshell and got this error :
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/conf/init.py", line 39, in _setup % (desc, ENVIRONMENT_VARIABLE)) django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
I followed the instruction from this answer to use settings.configure()
from django.conf import settings
settings.configure()
It returned this message :
Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/conf/init.py", line 63, in configure raise RuntimeError('Settings already configured.') RuntimeError: Settings already configured.
When I ran python3 manage.py shell
it gives me this error :
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 28, in raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
All I want to do is use mySql instead of sqlite db.
How do I do this ?