WEB API independent

This commit is contained in:
tuyang.yhj 2023-06-29 18:53:52 +08:00
parent 91c1a766c3
commit 4abfa3c7e9
3 changed files with 18 additions and 0 deletions

View 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)

View File

@ -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))

View File

@ -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