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

Function get_chart_data_ds

backend/apps/chat/curd/chat.py:246–265  ·  view source on GitHub ↗
(session: SessionDep,ds_id,sql)

Source from the content-addressed store, hash-verified

244 return get_chart_data_ds(session,row.datasource, row.sql)
245
246def get_chart_data_ds(session: SessionDep,ds_id,sql):
247 json_result: Dict[str, Any] = {'status': 'success','data':[],'message':''}
248 try:
249 datasource = get_ds(session,ds_id)
250 if datasource is None:
251 json_result['status'] = 'failed'
252 json_result['message'] = 'Datasource not found'
253 return json_result
254 else:
255 result = exec_sql(ds=datasource,sql=sql, origin_column=False)
256 _data = DataFormat.convert_large_numbers_in_object_array(result.get('data'))
257 _data = DataFormat.normalize_qualified_sql_column_keys_in_object_array(_data)
258 json_result['data'] = _data
259 return json_result
260 except Exception as e:
261 SQLBotLogUtil.error(f"Function failed: {e}")
262 json_result['status'] = 'failed'
263 json_result['message'] = f"{e}"
264 pass
265 return json_result
266
267def get_chat_chart_data(session: SessionDep, chat_record_id: int):
268 stmt = select(ChatRecord.data).where(and_(ChatRecord.id == chat_record_id))

Callers 2

load_resourceFunction · 0.90

Calls 6

get_dsFunction · 0.90
exec_sqlFunction · 0.90
errorMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected