Don't import Sqlite3Engine unless running synapse with sqlite3

This commit is contained in:
Andrew Morgan 2020-03-25 15:42:25 +00:00
parent 8895c38202
commit f5fd9b98c7

View file

@ -15,8 +15,6 @@
import platform
from ._base import BaseDatabaseEngine, IncorrectDatabaseSetup
from .postgres import PostgresEngine
from .sqlite import Sqlite3Engine
def create_engine(database_config) -> BaseDatabaseEngine:
@ -24,6 +22,7 @@ def create_engine(database_config) -> BaseDatabaseEngine:
if name == "sqlite3":
import sqlite3
from .sqlite import Sqlite3Engine
return Sqlite3Engine(sqlite3, database_config)
@ -34,6 +33,8 @@ def create_engine(database_config) -> BaseDatabaseEngine:
else:
import psycopg2 # type: ignore
from .postgres import PostgresEngine
return PostgresEngine(psycopg2, database_config)
raise RuntimeError("Unsupported database engine '%s'" % (name,))