mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-21 01:34:24 +00:00
WEB API independent
This commit is contained in:
parent
91c1a766c3
commit
4abfa3c7e9
10
pilot/connections/rdbms/py_study/study_data.py
Normal file
10
pilot/connections/rdbms/py_study/study_data.py
Normal file
@ -0,0 +1,10 @@
|
||||
from pilot.common.sql_database import Database
|
||||
from pilot.configs.config import Config
|
||||
|
||||
CFG = Config()
|
||||
|
||||
if __name__ == "__main__":
|
||||
connect = CFG.local_db.get_session("gpt-user")
|
||||
datas = CFG.local_db.run(connect, "SELECT * FROM users; ")
|
||||
|
||||
print(datas)
|
@ -65,6 +65,12 @@ class ChatDashboard(BaseChat):
|
||||
try:
|
||||
datas = self.database.run(self.db_connect, chart_item.sql)
|
||||
chart_data: ChartData = ChartData()
|
||||
chart_data.chart_sql = chart_item['sql']
|
||||
chart_data.chart_type = chart_item['showcase']
|
||||
chart_data.chart_name = chart_item['title']
|
||||
chart_data.chart_desc = chart_item['thoughts']
|
||||
chart_data.column_name = datas[0]
|
||||
chart_data.values =datas
|
||||
except Exception as e:
|
||||
# TODO 修复流程
|
||||
print(str(e))
|
||||
|
@ -4,7 +4,9 @@ from typing import TypeVar, Union, List, Generic, Any
|
||||
|
||||
class ChartData(BaseModel):
|
||||
chart_uid: str
|
||||
chart_name: str
|
||||
chart_type: str
|
||||
chart_desc: str
|
||||
chart_sql: str
|
||||
column_name: List
|
||||
values: List
|
||||
|
Loading…
Reference in New Issue
Block a user