From 9b603a9e84e08902aafc0b45bbadae5788a7dd00 Mon Sep 17 00:00:00 2001 From: mmomjian <50788000+mmomjian@users.noreply.github.com> Date: Sat, 6 Jan 2024 06:39:18 -0500 Subject: [PATCH] Add DB options support (#745) * Update base.py allow postgres SSL * Update base.py * Update database.md documentation * Update database.md * Update database.md * Update database.md Docs specified that postgres was the default variable, but settings/base.py:100-115 uses SQLite as default. * Adjust documentation language --------- Co-authored-by: Christopher Charbonneau Wells <10456740+cdubz@users.noreply.github.com> --- babybuddy/settings/base.py | 2 ++ docs/configuration/database.md | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/babybuddy/settings/base.py b/babybuddy/settings/base.py index 7e06940e..a517c435 100644 --- a/babybuddy/settings/base.py +++ b/babybuddy/settings/base.py @@ -111,6 +111,8 @@ if os.getenv("DB_HOST"): config["HOST"] = os.getenv("DB_HOST") if os.getenv("DB_PORT"): config["PORT"] = os.getenv("DB_PORT") +if os.getenv("DB_OPTIONS"): + config["OPTIONS"] = os.getenv("DB_OPTIONS") DATABASES = {"default": config} diff --git a/docs/configuration/database.md b/docs/configuration/database.md index a097c29f..1d4daea6 100644 --- a/docs/configuration/database.md +++ b/docs/configuration/database.md @@ -2,7 +2,7 @@ ## `DB_ENGINE` -*Default:* `django.db.backends.postgresql` +*Default:* `django.db.backends.sqlite3` The database engine utilized for the deployment. @@ -10,31 +10,37 @@ See also [Django's documentation on the ENGINE setting](https://docs.djangoproje ## `DB_HOST` -*Default:* `db` +*Default:* unset The name of the database host for the deployment. ## `DB_NAME` -*Default:* `postgres` +*Default:* `BASE_DIR/data/db.sqlite3` The name of the database table utilized for the deployment. ## `DB_PASSWORD` -*Default:* `None` +*Default:* unset The password for the database user for the deployment. In the default example, this is the root PostgreSQL password. ## `DB_PORT` -*Default:* `5432` +*Default:* unset -The listening port for the database. The default port is 5432 for PostgreSQL. +The listening port for the database. The default port for PostgreSQL is 5432. ## `DB_USER` -*Default:* `postgres` +*Default:* unset The database username utilized for the deployment. + +## `DB_OPTIONS` + +*Default:* unset + +Additional options to pass to the database library. See the [Django Databases documentation](https://docs.djangoproject.com/en/5.0/ref/databases/) for examples. To enforce an SSL connection to the database, use `{'sslmode': 'require'}`.