mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
refactor: Optimization Elasticsearch error prompt
This commit is contained in:
@@ -8,6 +8,7 @@ import requests
|
||||
from elasticsearch import Elasticsearch
|
||||
|
||||
from apps.datasource.models.datasource import DatasourceConf
|
||||
from common.error import SingleMessageError
|
||||
|
||||
|
||||
def get_es_connect(conf: DatasourceConf):
|
||||
@@ -109,6 +110,8 @@ def get_es_data_by_http(conf: DatasourceConf, sql: str):
|
||||
|
||||
# print(response.json())
|
||||
res = response.json()
|
||||
if res.get('error'):
|
||||
raise SingleMessageError(json.dumps(res))
|
||||
fields = res.get('columns')
|
||||
result = res.get('rows')
|
||||
return result, fields
|
||||
|
||||
Reference in New Issue
Block a user