(session: SessionDep,ds_id,sql)
| 244 | return get_chart_data_ds(session,row.datasource, row.sql) |
| 245 | |
| 246 | def 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 | |
| 267 | def get_chat_chart_data(session: SessionDep, chat_record_id: int): |
| 268 | stmt = select(ChatRecord.data).where(and_(ChatRecord.id == chat_record_id)) |
no test coverage detected