mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
feat: support Elasticsearch datasource #108
This commit is contained in:
@@ -434,4 +434,4 @@ def exec_sql(ds: CoreDatasource | AssistantOutDsSchema, sql: str, origin_column=
|
||||
return {"fields": columns, "data": result_list,
|
||||
"sql": bytes.decode(base64.b64encode(bytes(sql, 'utf-8')))}
|
||||
except Exception as ex:
|
||||
raise ParseSQLResultError(str(ex))
|
||||
raise Exception(str(ex))
|
||||
|
||||
@@ -63,7 +63,7 @@ def get_es_fields(conf: DatasourceConf, table_name: str):
|
||||
def get_es_data(conf: DatasourceConf, sql: str, table_name: str):
|
||||
r = requests.post(f"{conf.host}/_sql/translate", json={"query": sql})
|
||||
if r.json().get('error'):
|
||||
raise BaseException(f'{json.dumps(r.json())}')
|
||||
print(json.dumps(r.json()))
|
||||
|
||||
es_client = get_es_connect(conf)
|
||||
response = es_client.search(
|
||||
|
||||
Reference in New Issue
Block a user