I've put together a summary to make it easier to do when you end up changing the database used by Django. SQLite3
settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
MySQL
settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'DATABASE', #Database name
'USER': 'USER', #User ID
'PASSWORD': 'password', #User ID password
'HOST': 'localhost', #hostname
'PORT': '3306',
}
}
Required libraries: mysqlclient You can use PyMySQL, but mysqlclient is recommended.
POSTGRESQL
settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'DATABASE', #Database name
'USER': 'USER', #User ID
'PASSWORD': 'password', #User ID password
'HOST': 'localhost', #hostname
'PORT': '5432',
}
}
Required library: psycopg2
Recommended Posts