MCPcopy Create free account
hub / github.com/dataease/SQLBot / save_error_message

Function save_error_message

backend/apps/chat/curd/chat.py:1088–1117  ·  view source on GitHub ↗
(session: SessionDep, record_id: int, message: str)

Source from the content-addressed store, hash-verified

1086
1087
1088def save_error_message(session: SessionDep, record_id: int, message: str) -> ChatRecord:
1089 if not record_id:
1090 raise Exception("Record id cannot be None")
1091 record = get_chat_record_by_id(session, record_id)
1092
1093 record.error = message
1094 record.finish = True
1095 record.finish_time = datetime.datetime.now()
1096
1097 result = ChatRecord(**record.model_dump())
1098
1099 stmt = update(ChatRecord).where(and_(ChatRecord.id == record.id)).values(
1100 error=record.error,
1101 finish=record.finish,
1102 finish_time=record.finish_time
1103 )
1104
1105 session.execute(stmt)
1106
1107 session.commit()
1108
1109 # log error finish
1110 stmt = update(ChatLog).where(and_(ChatLog.pid == record.id, ChatLog.finish_time.is_(None))).values(
1111 finish_time=record.finish_time,
1112 error=True
1113 )
1114 session.execute(stmt)
1115 session.commit()
1116
1117 return result
1118
1119
1120def save_sql_exec_data(session: SessionDep, record_id: int, data: str) -> ChatRecord:

Callers 1

save_errorMethod · 0.90

Calls 4

ChatRecordClass · 0.90
get_chat_record_by_idFunction · 0.85
updateFunction · 0.50
valuesMethod · 0.45

Tested by

no test coverage detected