Skip to content

Commit 399754c

Browse files
committed
feat: ds check
1 parent 0b414a9 commit 399754c

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

backend/apps/datasource/api/datasource.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from apps.db.engine import create_table, get_data_engine, insert_data
1010
from common.core.deps import SessionDep, CurrentUser, Trans
11+
from common.utils.utils import SQLBotLogUtil
1112
from ..crud.datasource import get_datasource_list, check_status, create_ds, update_ds, delete_ds, getTables, getFields, \
1213
execSql, update_table_and_fields, getTablesByDs, chooseTables, preview, updateTable, updateField, get_ds, fieldEnum
1314
from ..crud.field import get_fields_by_table_id
@@ -60,7 +61,11 @@ async def get_tables(session: SessionDep, id: int):
6061

6162
@router.post("/getTablesByConf")
6263
async def get_tables_by_conf(session: SessionDep, ds: CoreDatasource):
63-
return getTablesByDs(session, ds)
64+
try:
65+
return getTablesByDs(session, ds)
66+
except Exception as e:
67+
SQLBotLogUtil.error(f"get table failed: {e}")
68+
raise HTTPException(status_code=500, detail=f'Get table Failed: {e.args}')
6469

6570

6671
@router.post("/getFields/{id}/{table_name}")
@@ -100,7 +105,11 @@ async def edit_field(session: SessionDep, field: CoreField):
100105

101106
@router.post("/previewData/{id}")
102107
async def edit_local(session: SessionDep, current_user: CurrentUser, id: int, data: TableObj):
103-
return preview(session, current_user, id, data)
108+
try:
109+
return preview(session, current_user, id, data)
110+
except Exception as e:
111+
SQLBotLogUtil.error(f"Preview failed: {e}")
112+
raise HTTPException(status_code=500, detail=f'Preview Failed: {e.args}')
104113

105114

106115
@router.post("/fieldEnum/{id}")

backend/apps/datasource/crud/datasource.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def getTables(session: SessionDep, id: int):
134134

135135

136136
def getTablesByDs(session: SessionDep, ds: CoreDatasource):
137-
check_status(session, ds, True)
137+
# check_status(session, ds, True)
138138
tables = get_tables(ds)
139139
return tables
140140

@@ -241,7 +241,7 @@ def updateField(session: SessionDep, field: CoreField):
241241

242242
def preview(session: SessionDep, current_user: CurrentUser, id: int, data: TableObj):
243243
ds = session.query(CoreDatasource).filter(CoreDatasource.id == id).first()
244-
check_status(session, ds, True)
244+
# check_status(session, ds, True)
245245

246246
if data.fields is None or len(data.fields) == 0:
247247
return {"fields": [], "data": [], "sql": ''}

0 commit comments

Comments
 (0)