model: only pass "check_same_thread" arg for sqlite database (#1662)
This commit is contained in:
parent
42e9924273
commit
196bdc5101
@ -43,12 +43,9 @@ def get_engine(url: Optional[str] = None):
|
|||||||
)
|
)
|
||||||
# Print the SQL queries if the log level is INFO or lower.
|
# Print the SQL queries if the log level is INFO or lower.
|
||||||
echo_db_query = os.environ.get("SQLALCHEMY_ECHO") == "True"
|
echo_db_query = os.environ.get("SQLALCHEMY_ECHO") == "True"
|
||||||
return sqlmodel.create_engine(
|
# Needed for the admin dash on sqlite.
|
||||||
url,
|
connect_args = {"check_same_thread": False} if url.startswith("sqlite") else {}
|
||||||
echo=echo_db_query,
|
return sqlmodel.create_engine(url, echo=echo_db_query, connect_args=connect_args)
|
||||||
# Needed for the admin dash.
|
|
||||||
connect_args={"check_same_thread": False},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Model(Base, sqlmodel.SQLModel):
|
class Model(Base, sqlmodel.SQLModel):
|
||||||
|
Loading…
Reference in New Issue
Block a user