diff options
author | Erik Johnston <erik@matrix.org> | 2015-04-27 15:57:43 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-04-27 15:57:43 +0100 |
commit | 1ef66cc3bd541ee1e4a017cfdd008eacaec5bcf8 (patch) | |
tree | 6ca2f7d80fd164f9cba9b9a401a79b7ca9799513 /synapse/config/database.py | |
parent | Ensure check_same_thread is enabled for sqlite3 (diff) | |
download | synapse-1ef66cc3bd541ee1e4a017cfdd008eacaec5bcf8.tar.xz |
Move database configuration into config module
Diffstat (limited to 'synapse/config/database.py')
-rw-r--r-- | synapse/config/database.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/synapse/config/database.py b/synapse/config/database.py index f3d0898c09..190d119df4 100644 --- a/synapse/config/database.py +++ b/synapse/config/database.py @@ -15,6 +15,7 @@ from ._base import Config import os +import yaml class DatabaseConfig(Config): @@ -27,9 +28,27 @@ class DatabaseConfig(Config): self.event_cache_size = self.parse_size(args.event_cache_size) if args.database_config: - self.database_config = self.abspath(args.database_config) + with open(args.database_config) as f: + self.database_config = yaml.safe_load(f) else: - self.database_config = None + self.database_config = { + "name": "sqlite3", + "args": { + "database": self.database_path, + }, + } + + name = self.database_config.get("name", None) + if name == "psycopg2": + pass + elif name == "sqlite3": + self.database_config.setdefault("args", {}).update({ + "cp_min": 1, + "cp_max": 1, + "check_same_thread": False, + }) + else: + raise RuntimeError("Unsupported database type '%s'" % (name,)) @classmethod def add_arguments(cls, parser): |