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:
@@ -5,6 +5,7 @@ import json
|
||||
|
||||
import requests
|
||||
from elasticsearch import Elasticsearch
|
||||
from fastapi import HTTPException
|
||||
|
||||
from apps.datasource.models.datasource import DatasourceConf
|
||||
|
||||
@@ -61,7 +62,8 @@ 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})
|
||||
# print(json.dumps(r.json()))
|
||||
if r.json().get('error'):
|
||||
raise HTTPException(status_code=500, detail=f': {json.dumps(r.json())}')
|
||||
|
||||
es_client = get_es_connect(conf)
|
||||
response = es_client.search(
|
||||
|
||||
Reference in New Issue
Block a user