Skip to content

Commit 40699d2

Browse files
committed
Merge branch 'main' of https://github.com/dataease/SQLBot
2 parents cd87244 + 1161be9 commit 40699d2

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ curl -o docker-compose.yaml https://raw.githubusercontent.com/dataease/SQLBot/ma
3333
docker compose up -d
3434
```
3535

36-
你也可以通过 [1Panel 应用商店](https://apps.fit2cloud.com/1panel) 快速部署 SQLBot;
36+
你也可以通过 [1Panel 应用商店](https://apps.fit2cloud.com/1panel) 快速部署 SQLBot。
37+
38+
如果是内网环境,你可以通过 [离线安装包方式](https://community.fit2cloud.com/#/products/sqlbot/downloads) 部署 SQLBot。
39+
3740

3841
### 访问方式
3942

backend/apps/datasource/api/datasource.py

Lines changed: 8 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
@@ -301,6 +301,11 @@ def inner():
301301

302302

303303
def insert_pg(df, tableName, engine):
304+
# fix field type
305+
for i in range(len(df.dtypes)):
306+
if str(df.dtypes[i]) == 'uint64':
307+
df[str(df.columns[i])] = df[str(df.columns[i])].astype('string')
308+
304309
conn = engine.raw_connection()
305310
cursor = conn.cursor()
306311
try:
@@ -322,7 +327,8 @@ def insert_pg(df, tableName, engine):
322327
)
323328
conn.commit()
324329
except Exception as e:
325-
pass
330+
traceback.print_exc()
331+
raise HTTPException(400, str(e))
326332
finally:
327333
cursor.close()
328334
conn.close()

backend/apps/db/db.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,19 @@ def check_connection(trans: Trans, ds: CoreDatasource, is_raise: bool = False):
155155
return False
156156

157157

158-
def get_version(ds: CoreDatasource):
159-
conf = DatasourceConf(**json.loads(aes_decrypt(ds.configuration))) if ds.type != "excel" else get_engine_config()
158+
def get_version(ds: CoreDatasource | AssistantOutDsSchema):
159+
conf = None
160+
if isinstance(ds, CoreDatasource):
161+
conf = DatasourceConf(**json.loads(aes_decrypt(ds.configuration))) if ds.type != "excel" else get_engine_config()
162+
if isinstance(ds, AssistantOutDsSchema):
163+
conf = DatasourceConf()
164+
conf.host = ds.host
165+
conf.port = ds.port
166+
conf.username = ds.user
167+
conf.password = ds.password
168+
conf.database = ds.dataBase
169+
conf.dbSchema = ds.db_schema
170+
conf.timeout = 10
160171
db = DB.get_db(ds.type)
161172
sql = get_version_sql(ds, conf)
162173
try:

backend/apps/system/models/system_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class AiModelBase:
1414

1515
class AiModelDetail(SnowflakeBase, AiModelBase, table=True):
1616
__tablename__ = "ai_model"
17-
api_key: str | None = Field(max_length=255, nullable=True)
18-
api_domain: str = Field(max_length=255, nullable=False)
17+
api_key: str | None = Field(nullable=True)
18+
api_domain: str = Field(nullable=False)
1919
protocol: int = Field(nullable=False, default = 1)
2020
config: str = Field(sa_type = Text())
2121
status: int = Field(nullable=False, default = 1)

0 commit comments

Comments
 (0)