More db compatibility

This commit is contained in:
Antoine Bertin 2021-04-28 09:23:49 +02:00
commit 5c41f5dfd7
No known key found for this signature in database
GPG key ID: 09851B52754E2327
2 changed files with 4 additions and 5 deletions

View file

@ -7,7 +7,6 @@ import dotenv
from pydantic import BaseSettings, Field, validator from pydantic import BaseSettings, Field, validator
APP_VERSION = "v0.5.0beta" APP_VERSION = "v0.5.0beta"
DB_VERSION = "v0.5.0"
CWD = Path(__file__).parent CWD = Path(__file__).parent
BASE_DIR = CWD.parent.parent BASE_DIR = CWD.parent.parent
@ -83,7 +82,7 @@ app_dirs = AppDirectories(CWD, DATA_DIR)
def determine_sqlite_path() -> str: def determine_sqlite_path() -> str:
db_path = app_dirs.DATA_DIR.joinpath("db", "mealie.db") db_path = app_dirs.DATA_DIR.joinpath("mealie.db")
return "sqlite:///" + str(db_path.absolute()) return "sqlite:///" + str(db_path.absolute())

View file

@ -3,14 +3,14 @@ from sqlalchemy.orm import sessionmaker
def sql_global_init(db_url: str): def sql_global_init(db_url: str):
thread_safe = True connect_args = {}
if "sqlite" in db_url: if "sqlite" in db_url:
thread_safe = False connect_args["check_same_thread"] = False
engine = sa.create_engine( engine = sa.create_engine(
db_url, db_url,
echo=False, echo=False,
connect_args={"check_same_thread": thread_safe}, connect_args=connect_args,
) )
return sessionmaker(autocommit=False, autoflush=False, bind=engine) return sessionmaker(autocommit=False, autoflush=False, bind=engine)