Dynamic same thread verification

This commit is contained in:
Colin Goutte 2021-09-29 10:14:05 +02:00
parent 84cd8c5ef4
commit 0f547f9ee6
1 changed files with 2 additions and 1 deletions

View File

@ -6,7 +6,8 @@ SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db"
# SQLALCHEMY_DATABASE_URL = "postgresql://user:password@postgresserver/db"
engine = create_engine(
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": not ("sqlite" in SQLALCHEMY_DATABASE_URL)},
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)