mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
aurweb.db: only pass check_same_thread with sqlite
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
25393dc326
commit
b41422450a
1 changed files with 9 additions and 4 deletions
13
aurweb/db.py
13
aurweb/db.py
|
@ -49,10 +49,15 @@ def get_engine():
|
|||
from sqlalchemy import create_engine
|
||||
global engine
|
||||
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()
|
||||
|
||||
return engine
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue