Refactor database config source

Switched database settings to use the centralized SETTINGS variable instead of the previous CONFIG. This ensures consistency across configuration management and aligns with recent changes to the settings infrastructure, facilitating easier adjustments and maintenance of database parameters.
This commit is contained in:
Kumi 2023-12-04 16:35:23 +01:00
parent 57119dfc4c
commit 8142d62f37
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -71,15 +71,15 @@ WSGI_APPLICATION = 'expalert.wsgi.application'
# Database # Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases # https://docs.djangoproject.com/en/4.2/ref/settings/#databases
if (dbtype := "MySQL") in CONFIG or (dbtype := "MariaDB") in CONFIG: if (dbtype := "MySQL") in SETTINGS or (dbtype := "MariaDB") in SETTINGS:
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.db.backends.mysql',
'NAME': CONFIG.get(dbtype, "Database"), 'NAME': SETTINGS.get(dbtype, "Database"),
'USER': CONFIG.get(dbtype, "Username"), 'USER': SETTINGS.get(dbtype, "Username"),
'PASSWORD': CONFIG.get(dbtype, "Password"), 'PASSWORD': SETTINGS.get(dbtype, "Password"),
'HOST': CONFIG.get(dbtype, "Host", fallback="localhost"), 'HOST': SETTINGS.get(dbtype, "Host", fallback="localhost"),
'PORT': CONFIG.getint(dbtype, "Port", fallback=3306) 'PORT': SETTINGS.getint(dbtype, "Port", fallback=3306)
} }
} }