mirror of
https://github.com/sissbruecker/linkding
synced 2024-11-23 20:03:04 +00:00
Add database options (#406)
* adding support for database connection options * a better default
This commit is contained in:
parent
353ba433f0
commit
d1819c6503
3 changed files with 12 additions and 0 deletions
|
@ -45,3 +45,5 @@ LD_DB_HOST=
|
|||
# Port use to connect to the database server
|
||||
# Should use the default port if not set
|
||||
LD_DB_PORT=
|
||||
# Any additional options to pass to the database (default: {})
|
||||
LD_DB_OPTIONS=
|
||||
|
|
|
@ -150,6 +150,12 @@ Values: `Integer` | Default = None
|
|||
The port of the database server.
|
||||
Should use the default port if left empty, for example `5432` for PostgresSQL.
|
||||
|
||||
### `LD_DB_OPTIONS`
|
||||
|
||||
Values: `String` | Default = `{}`
|
||||
|
||||
A json string with additional options for the database. Passed directly to OPTIONS.
|
||||
|
||||
### `LD_FAVICON_PROVIDER`
|
||||
|
||||
Values: `String` | Default = `https://t1.gstatic.com/faviconV2?url={url}&client=SOCIAL&type=FAVICON`
|
||||
|
|
|
@ -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 = {
|
||||
|
|
Loading…
Reference in a new issue