From 3f1f03e03c904f1c8202a692bc18ca153c529f50 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Sun, 16 May 2021 01:40:19 -0700 Subject: [PATCH] aurweb.db: only pass check_same_thread with sqlite Signed-off-by: Kevin Morris --- aurweb/db.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/aurweb/db.py b/aurweb/db.py index 49e0abd2..f5530bcf 100644 --- a/aurweb/db.py +++ b/aurweb/db.py @@ -59,10 +59,12 @@ def get_engine(): global engine, session, Session if engine is None: - engine = create_engine(get_sqlalchemy_url(), - # check_same_thread is for a SQLite technicality - # https://fastapi.tiangolo.com/tutorial/sql-databases/#note - connect_args={"check_same_thread": False}) + connect_args = dict() + if aurweb.config.get("database", "backend") == "sqlite": + # check_same_thread is for a SQLite technicality + # https://fastapi.tiangolo.com/tutorial/sql-databases/#note + connect_args["check_same_thread"] = False + engine = create_engine(get_sqlalchemy_url(), connect_args=connect_args) Session = sessionmaker(autocommit=False, autoflush=False, bind=engine) session = Session()