mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 06:23:34 -07:00
add thread_safe - required for sqlite
This commit is contained in:
parent
e7435beaad
commit
f65f718333
1 changed files with 6 additions and 6 deletions
|
@ -1,16 +1,16 @@
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from mealie.db.models.model_base import SqlAlchemyBase
|
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
|
|
||||||
def sql_global_init(db_url: str):
|
def sql_global_init(db_url: str):
|
||||||
|
thread_safe = True
|
||||||
|
if "sqlite" in db_url:
|
||||||
|
thread_safe = False
|
||||||
|
|
||||||
engine = sa.create_engine(
|
engine = sa.create_engine(
|
||||||
db_url,
|
db_url,
|
||||||
echo=False,
|
echo=False,
|
||||||
|
connect_args={"check_same_thread": thread_safe},
|
||||||
)
|
)
|
||||||
|
|
||||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
return sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||||
|
|
||||||
return SessionLocal
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue