From ad16f6221dde831afc068a460856dccd8ef0bfb9 Mon Sep 17 00:00:00 2001 From: junjun Date: Mon, 1 Sep 2025 10:24:13 +0800 Subject: [PATCH] fix: fix mysql check status error --- backend/apps/db/db.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/apps/db/db.py b/backend/apps/db/db.py index f6c1b181..7dce8065 100644 --- a/backend/apps/db/db.py +++ b/backend/apps/db/db.py @@ -106,6 +106,8 @@ def check_connection(trans: Trans, ds: CoreDatasource, is_raise: bool = False): conn = get_engine(ds, 10) try: with conn.connect() as connection: + if ds.type == 'mysql': + connection.execute(text('select 1')).fetchall() SQLBotLogUtil.info("success") return True except Exception as e: @@ -158,7 +160,8 @@ def check_connection(trans: Trans, ds: CoreDatasource, is_raise: bool = False): def get_version(ds: CoreDatasource | AssistantOutDsSchema): conf = None if isinstance(ds, CoreDatasource): - conf = DatasourceConf(**json.loads(aes_decrypt(ds.configuration))) if ds.type != "excel" else get_engine_config() + conf = DatasourceConf( + **json.loads(aes_decrypt(ds.configuration))) if ds.type != "excel" else get_engine_config() if isinstance(ds, AssistantOutDsSchema): conf = DatasourceConf() conf.host = ds.host