diff --git a/expalert/settings.py b/expalert/settings.py index 649b235..a73398a 100644 --- a/expalert/settings.py +++ b/expalert/settings.py @@ -71,12 +71,25 @@ WSGI_APPLICATION = 'expalert.wsgi.application' # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', +if (dbtype := "MySQL") in CONFIG or (dbtype := "MariaDB") in CONFIG: + 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) + } + } + +else: + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } } -} # Password validation