summary refs log tree commit diff
diff options
context:
space:
mode:
authorH. Shay <hillerys@element.io>2022-06-06 20:33:04 -0700
committerH. Shay <hillerys@element.io>2022-06-06 20:33:04 -0700
commit950b0cfe12c3e0a4af0daacf4972d6f894f290e3 (patch)
treed774dfe21ae3d207f46d654d11d98a491075dec5
parentRemove remaining pieces of groups code. (#12966) (diff)
downloadsynapse-950b0cfe12c3e0a4af0daacf4972d6f894f290e3.tar.xz
conditionally import sqlite and postgres in engines/__init__.py
-rw-r--r--synapse/storage/engines/__init__.py6
-rw-r--r--synapse/storage/engines/postgres.py3
2 files changed, 6 insertions, 3 deletions
diff --git a/synapse/storage/engines/__init__.py b/synapse/storage/engines/__init__.py

index f51b3d228e..6b0024c611 100644 --- a/synapse/storage/engines/__init__.py +++ b/synapse/storage/engines/__init__.py
@@ -14,17 +14,19 @@ from typing import Any, Mapping from ._base import BaseDatabaseEngine, IncorrectDatabaseSetup -from .postgres import PostgresEngine -from .sqlite import Sqlite3Engine def create_engine(database_config: Mapping[str, Any]) -> BaseDatabaseEngine: name = database_config["name"] if name == "sqlite3": + from .sqlite import Sqlite3Engine + return Sqlite3Engine(database_config) if name == "psycopg2": + from .postgres import PostgresEngine + return PostgresEngine(database_config) raise RuntimeError("Unsupported database engine '%s'" % (name,)) diff --git a/synapse/storage/engines/postgres.py b/synapse/storage/engines/postgres.py
index 391f8ed24a..7b5dc4413b 100644 --- a/synapse/storage/engines/postgres.py +++ b/synapse/storage/engines/postgres.py
@@ -15,6 +15,8 @@ import logging from typing import TYPE_CHECKING, Any, Mapping, NoReturn, Optional, Tuple, cast +import psycopg2 + from synapse.storage.engines._base import ( BaseDatabaseEngine, IncorrectDatabaseSetup, @@ -23,7 +25,6 @@ from synapse.storage.engines._base import ( from synapse.storage.types import Cursor if TYPE_CHECKING: - import psycopg2 # noqa: F401 from synapse.storage.database import LoggingDatabaseConnection