mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2025-04-20 01:26:43 +00:00
raise error on invalid database backend
This commit is contained in:
parent
5870f3a96b
commit
6e5f0f237a
1 changed files with 15 additions and 11 deletions
|
@ -30,10 +30,11 @@ def get_database(state: State, migrate: bool = True) -> Database[Connection]:
|
|||
|
||||
db: Database[Connection]
|
||||
|
||||
if state.config.db_type == "sqlite":
|
||||
match state.config.db_type:
|
||||
case "sqlite" | "sqlite3":
|
||||
db = Database.sqlite(state.config.sqlite_path, **options)
|
||||
|
||||
elif state.config.db_type == "postgres":
|
||||
case "postgres" | "postgresql":
|
||||
db = Database.postgresql(
|
||||
state.config.pg_name,
|
||||
state.config.pg_host,
|
||||
|
@ -43,6 +44,9 @@ def get_database(state: State, migrate: bool = True) -> Database[Connection]:
|
|||
**options
|
||||
)
|
||||
|
||||
case _:
|
||||
raise RuntimeError(f"Invalid database backend: {state.config.db_type}")
|
||||
|
||||
db.load_prepared_statements(File.from_resource("relay", "data/statements.sql"))
|
||||
db.connect()
|
||||
|
||||
|
|
Loading…
Reference in a new issue