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
# 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 = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': CONFIG.get(dbtype, "Database"),
'USER': CONFIG.get(dbtype, "Username"),
'PASSWORD': CONFIG.get(dbtype, "Password"),
'HOST': CONFIG.get(dbtype, "Host", fallback="localhost"),
'PORT': CONFIG.getint(dbtype, "Port", fallback=3306)
'NAME': SETTINGS.get(dbtype, "Database"),
'USER': SETTINGS.get(dbtype, "Username"),
'PASSWORD': SETTINGS.get(dbtype, "Password"),
'HOST': SETTINGS.get(dbtype, "Host", fallback="localhost"),
'PORT': SETTINGS.getint(dbtype, "Port", fallback=3306)
}
}