feat: timeout

This commit is contained in:
junjun
2025-07-29 11:15:21 +08:00
parent 2efad70b8d
commit f689cbc203
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ def get_ds(session: SessionDep, id: int):
def check_status(session: SessionDep, ds: CoreDatasource, is_raise: bool = False):
conn = get_engine(ds)
conn = get_engine(ds, 5)
try:
with conn.connect() as connection:
SQLBotLogUtil.info("success")
+2 -2
View File
@@ -52,10 +52,10 @@ def get_uri_from_config(type: str, conf: DatasourceConf) -> str:
return db_url
def get_engine(ds: CoreDatasource) -> Engine:
def get_engine(ds: CoreDatasource, timeout: int = 30) -> Engine:
conf = DatasourceConf(**json.loads(aes_decrypt(ds.configuration))) if ds.type != "excel" else get_engine_config()
if conf.timeout is None:
conf.timeout = 30
conf.timeout = timeout
if ds.type == "pg" and (conf.dbSchema is not None and conf.dbSchema != ""):
engine = create_engine(get_uri(ds),
connect_args={"options": f"-c search_path={urllib.parse.quote(conf.dbSchema)}",