Skip to content

Commit 78b3d6f

Browse files
committed
refactor: throw upload excel exception
1 parent 224b4a6 commit 78b3d6f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

backend/apps/datasource/api/datasource.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import pandas as pd
1111
from fastapi import APIRouter, File, UploadFile, HTTPException
1212

13+
from apps.db.db import get_schema
1314
from apps.db.engine import get_engine_conn
1415
from common.core.config import settings
1516
from common.core.deps import SessionDep, CurrentUser, Trans
@@ -20,7 +21,6 @@
2021
from ..crud.field import get_fields_by_table_id
2122
from ..crud.table import get_tables_by_ds_id
2223
from ..models.datasource import CoreDatasource, CreateDatasource, TableObj, CoreTable, CoreField
23-
from apps.db.db import get_schema
2424

2525
router = APIRouter(tags=["datasource"], prefix="/datasource")
2626
path = settings.EXCEL_PATH
@@ -327,7 +327,8 @@ def insert_pg(df, tableName, engine):
327327
)
328328
conn.commit()
329329
except Exception as e:
330-
pass
330+
traceback.print_exc()
331+
raise HTTPException(400, str(e))
331332
finally:
332333
cursor.close()
333334
conn.close()

0 commit comments

Comments
 (0)