MCPcopy Index your code
hub / github.com/dataease/SQLBot / save_sql

Function save_sql

backend/apps/chat/curd/chat.py:1010–1028  ·  view source on GitHub ↗
(session: SessionDep, record_id: int, sql: str)

Source from the content-addressed store, hash-verified

1008
1009
1010def save_sql(session: SessionDep, record_id: int, sql: str) -> ChatRecord:
1011 if not record_id:
1012 raise Exception("Record id cannot be None")
1013
1014 record = get_chat_record_by_id(session, record_id)
1015
1016 record.sql = sql
1017
1018 result = ChatRecord(**record.model_dump())
1019
1020 stmt = update(ChatRecord).where(and_(ChatRecord.id == record.id)).values(
1021 sql=record.sql
1022 )
1023
1024 session.execute(stmt)
1025
1026 session.commit()
1027
1028 return result
1029
1030
1031def save_chart_answer(session: SessionDep, record_id: int, answer: str) -> ChatRecord:

Callers 1

check_save_sqlMethod · 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