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`
This commit is contained in:
alulala 2025-04-25 13:29:47 +08:00 committed by GitHub
parent 02cc867c06
commit eead838353
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -212,6 +212,12 @@ class CommonService:
# data: Updated field values # data: Updated field values
# Returns: # Returns:
# Number of records updated # 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_time"] = current_timestamp()
data["update_date"] = datetime_format(datetime.now()) data["update_date"] = datetime_format(datetime.now())
num = cls.model.update(data).where(cls.model.id == pid).execute() num = cls.model.update(data).where(cls.model.id == pid).execute()