mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
Merge branch 'main' of https://github.com/dataease/SQLBot
This commit is contained in:
@@ -33,7 +33,10 @@ curl -o docker-compose.yaml https://raw.githubusercontent.com/dataease/SQLBot/ma
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
你也可以通过 [1Panel 应用商店](https://apps.fit2cloud.com/1panel) 快速部署 SQLBot;
|
||||
你也可以通过 [1Panel 应用商店](https://apps.fit2cloud.com/1panel) 快速部署 SQLBot。
|
||||
|
||||
如果是内网环境,你可以通过 [离线安装包方式](https://community.fit2cloud.com/#/products/sqlbot/downloads) 部署 SQLBot。
|
||||
|
||||
|
||||
### 访问方式
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import orjson
|
||||
import pandas as pd
|
||||
from fastapi import APIRouter, File, UploadFile, HTTPException
|
||||
|
||||
from apps.db.db import get_schema
|
||||
from apps.db.engine import get_engine_conn
|
||||
from common.core.config import settings
|
||||
from common.core.deps import SessionDep, CurrentUser, Trans
|
||||
@@ -20,7 +21,6 @@ from ..crud.datasource import get_datasource_list, check_status, create_ds, upda
|
||||
from ..crud.field import get_fields_by_table_id
|
||||
from ..crud.table import get_tables_by_ds_id
|
||||
from ..models.datasource import CoreDatasource, CreateDatasource, TableObj, CoreTable, CoreField
|
||||
from apps.db.db import get_schema
|
||||
|
||||
router = APIRouter(tags=["datasource"], prefix="/datasource")
|
||||
path = settings.EXCEL_PATH
|
||||
@@ -301,6 +301,11 @@ async def upload_excel(session: SessionDep, file: UploadFile = File(...)):
|
||||
|
||||
|
||||
def insert_pg(df, tableName, engine):
|
||||
# fix field type
|
||||
for i in range(len(df.dtypes)):
|
||||
if str(df.dtypes[i]) == 'uint64':
|
||||
df[str(df.columns[i])] = df[str(df.columns[i])].astype('string')
|
||||
|
||||
conn = engine.raw_connection()
|
||||
cursor = conn.cursor()
|
||||
try:
|
||||
@@ -322,7 +327,8 @@ def insert_pg(df, tableName, engine):
|
||||
)
|
||||
conn.commit()
|
||||
except Exception as e:
|
||||
pass
|
||||
traceback.print_exc()
|
||||
raise HTTPException(400, str(e))
|
||||
finally:
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
+13
-2
@@ -155,8 +155,19 @@ def check_connection(trans: Trans, ds: CoreDatasource, is_raise: bool = False):
|
||||
return False
|
||||
|
||||
|
||||
def get_version(ds: CoreDatasource):
|
||||
conf = DatasourceConf(**json.loads(aes_decrypt(ds.configuration))) if ds.type != "excel" else get_engine_config()
|
||||
def get_version(ds: CoreDatasource | AssistantOutDsSchema):
|
||||
conf = None
|
||||
if isinstance(ds, CoreDatasource):
|
||||
conf = DatasourceConf(**json.loads(aes_decrypt(ds.configuration))) if ds.type != "excel" else get_engine_config()
|
||||
if isinstance(ds, AssistantOutDsSchema):
|
||||
conf = DatasourceConf()
|
||||
conf.host = ds.host
|
||||
conf.port = ds.port
|
||||
conf.username = ds.user
|
||||
conf.password = ds.password
|
||||
conf.database = ds.dataBase
|
||||
conf.dbSchema = ds.db_schema
|
||||
conf.timeout = 10
|
||||
db = DB.get_db(ds.type)
|
||||
sql = get_version_sql(ds, conf)
|
||||
try:
|
||||
|
||||
@@ -14,8 +14,8 @@ class AiModelBase:
|
||||
|
||||
class AiModelDetail(SnowflakeBase, AiModelBase, table=True):
|
||||
__tablename__ = "ai_model"
|
||||
api_key: str | None = Field(max_length=255, nullable=True)
|
||||
api_domain: str = Field(max_length=255, nullable=False)
|
||||
api_key: str | None = Field(nullable=True)
|
||||
api_domain: str = Field(nullable=False)
|
||||
protocol: int = Field(nullable=False, default = 1)
|
||||
config: str = Field(sa_type = Text())
|
||||
status: int = Field(nullable=False, default = 1)
|
||||
|
||||
Reference in New Issue
Block a user