From eead8383537575695e355f3eefa469171ae7f736 Mon Sep 17 00:00:00 2001 From: alulala <61424174+Yue-Lyu123@users.noreply.github.com> Date: Fri, 25 Apr 2025 13:29:47 +0800 Subject: [PATCH] Fix pymysql interface error (#7295) ### What problem does this PR solve? According to the [[Rucongzhang](https://github.com/Rucongzhang)](https://github.com/infiniflow/ragflow/pull/7057#issuecomment-2827410047) I added DB reconnection strategy in function `update_by_id` --- api/db/services/common_service.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/db/services/common_service.py b/api/db/services/common_service.py index cf31a2a62..3af19ce4b 100644 --- a/api/db/services/common_service.py +++ b/api/db/services/common_service.py @@ -212,6 +212,12 @@ class CommonService: # data: Updated field values # Returns: # Number of records updated + try: + if not DB.is_connection_usable(): + DB.connect() + except Exception: + DB.close() + DB.connect() data["update_time"] = current_timestamp() data["update_date"] = datetime_format(datetime.now()) num = cls.model.update(data).where(cls.model.id == pid).execute()