-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(db): reuse connections for 5 minutes
- Loading branch information
1 parent
ba1ebb2
commit 002aa1d
Showing
2 changed files
with
36 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,35 @@ | ||
from __future__ import annotations | ||
|
||
from configurations.values import Value | ||
|
||
|
||
class DatabaseConfigMixin: | ||
DATABASES = { | ||
"default": { | ||
"ENGINE": "django.db.backends.postgresql", | ||
"HOST": "db", | ||
"USER": "fiesta", | ||
"NAME": "fiesta", | ||
"PASSWORD": "fiesta", | ||
}, | ||
"legacydb": { | ||
"ENGINE": "django.db.backends.mysql", | ||
"HOST": "legacydb", | ||
"NAME": "fiesta", | ||
# TODO: access to legacy db by standard user | ||
"USER": "root", | ||
"PASSWORD": "root", | ||
}, | ||
"wiki": { | ||
"ENGINE": "django.db.backends.sqlite3", | ||
# TODO: pass from ENV | ||
"NAME": "/usr/src/wiki/db/wiki.sqlite3", | ||
}, | ||
} | ||
DATABASE_CONN_MAX_AGE = Value(default=5 * 60) | ||
DATABASE_CONN_HEALTH_CHECKS = Value(default=True) | ||
|
||
@property | ||
def DATABASES(self): | ||
return { | ||
"default": { | ||
"ENGINE": "django.db.backends.postgresql", | ||
"HOST": "db", | ||
"USER": "fiesta", | ||
"NAME": "fiesta", | ||
"PASSWORD": "fiesta", | ||
"CONN_MAX_AGE": self.DATABASE_CONN_MAX_AGE, | ||
"CONN_HEALTH_CHECKS": self.DATABASE_CONN_HEALTH_CHECKS, | ||
}, | ||
"legacydb": { | ||
"ENGINE": "django.db.backends.mysql", | ||
"HOST": "legacydb", | ||
"NAME": "fiesta", | ||
# TODO: access to legacy db by standard user | ||
"USER": "root", | ||
"PASSWORD": "root", | ||
}, | ||
"wiki": { | ||
"ENGINE": "django.db.backends.sqlite3", | ||
# TODO: pass from ENV | ||
"NAME": "/usr/src/wiki/db/wiki.sqlite3", | ||
}, | ||
} |