core: load db from yml
This commit is contained in:
parent
8383df2441
commit
5f9befb5ee
|
@ -131,13 +131,19 @@ WSGI_APPLICATION = 'passbook.core.wsgi.application'
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
|
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {}
|
||||||
'default': {
|
for db_alias, db_config in CONFIG.get('databases').items():
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
if 'mysql' in db_config.get('engine'):
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
import pymysql
|
||||||
|
pymysql.install_as_MySQLdb()
|
||||||
|
DATABASES[db_alias] = {
|
||||||
|
'ENGINE': db_config.get('engine'),
|
||||||
|
'HOST': db_config.get('host'),
|
||||||
|
'NAME': db_config.get('name'),
|
||||||
|
'USER': db_config.get('user'),
|
||||||
|
'PASSWORD': db_config.get('password'),
|
||||||
|
'OPTIONS': db_config.get('options', {}),
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
|
||||||
|
|
Reference in New Issue