Add database options (#406)

* adding support for database connection options

* a better default
This commit is contained in:
Paul Lockaby
2023-05-18 00:31:13 -07:00
committed by GitHub
parent 353ba433f0
commit d1819c6503
3 changed files with 12 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import json
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
@@ -204,6 +205,7 @@ LD_DB_DATABASE = os.getenv('LD_DB_DATABASE', 'linkding')
LD_DB_USER = os.getenv('LD_DB_USER', 'linkding')
LD_DB_PASSWORD = os.getenv('LD_DB_PASSWORD', None)
LD_DB_PORT = os.getenv('LD_DB_PORT', None)
LD_DB_OPTIONS = json.loads(os.getenv('LD_DB_OPTIONS') or '{}')
if LD_DB_ENGINE == 'postgres':
default_database = {
@@ -213,11 +215,13 @@ if LD_DB_ENGINE == 'postgres':
'PASSWORD': LD_DB_PASSWORD,
'HOST': LD_DB_HOST,
'PORT': LD_DB_PORT,
'OPTIONS': LD_DB_OPTIONS,
}
else:
default_database = {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'data', 'db.sqlite3'),
'OPTIONS': LD_DB_OPTIONS,
}
DATABASES = {