mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -73,6 +73,7 @@ class DatasourceConf(BaseModel):
|
||||
filename: str = ''
|
||||
sheets: List = ''
|
||||
mode: str = ''
|
||||
timeout: int = 30
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
@@ -86,7 +87,8 @@ class DatasourceConf(BaseModel):
|
||||
"dbSchema": self.dbSchema,
|
||||
"filename": self.filename,
|
||||
"sheets": self.sheets,
|
||||
"mode": self.mode
|
||||
"mode": self.mode,
|
||||
"timeout": self.timeout
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,11 +48,17 @@ def get_uri(ds: CoreDatasource):
|
||||
|
||||
def get_engine(ds: CoreDatasource) -> Engine:
|
||||
conf = DatasourceConf(**json.loads(aes_decrypt(ds.configuration))) if ds.type != "excel" else get_engine_config()
|
||||
if conf.timeout is None:
|
||||
conf.timeout = 30
|
||||
if ds.type == "pg" and (conf.dbSchema is not None and conf.dbSchema != ""):
|
||||
engine = create_engine(get_uri(ds), connect_args={"options": f"-c search_path={conf.dbSchema}"},
|
||||
pool_timeout=30, pool_size=20, max_overflow=10)
|
||||
engine = create_engine(get_uri(ds),
|
||||
connect_args={"options": f"-c search_path={conf.dbSchema}",
|
||||
"connect_timeout": conf.timeout},
|
||||
pool_timeout=conf.timeout, pool_size=20, max_overflow=10)
|
||||
else:
|
||||
engine = create_engine(get_uri(ds), pool_timeout=30, pool_size=20, max_overflow=10)
|
||||
engine = create_engine(get_uri(ds), connect_args={"connect_timeout": conf.timeout}, pool_timeout=conf.timeout,
|
||||
pool_size=20,
|
||||
max_overflow=10)
|
||||
return engine
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ from common.core.config import settings
|
||||
def get_engine_config():
|
||||
return DatasourceConf(username=settings.POSTGRES_USER, password=settings.POSTGRES_PASSWORD,
|
||||
host=settings.POSTGRES_SERVER, port=settings.POSTGRES_PORT, database=settings.POSTGRES_DB,
|
||||
dbSchema="public")
|
||||
dbSchema="public", timeout=30) # read engine config
|
||||
|
||||
|
||||
def get_engine_uri(conf: DatasourceConf):
|
||||
@@ -23,7 +23,9 @@ def get_engine_uri(conf: DatasourceConf):
|
||||
def get_engine_conn():
|
||||
conf = get_engine_config()
|
||||
db_url = get_engine_uri(conf)
|
||||
engine = create_engine(db_url, connect_args={"options": f"-c search_path={conf.dbSchema}"}, pool_timeout=300,
|
||||
engine = create_engine(db_url,
|
||||
connect_args={"options": f"-c search_path={conf.dbSchema}", "connect_timeout": conf.timeout},
|
||||
pool_timeout=conf.timeout,
|
||||
pool_size=20,
|
||||
max_overflow=10)
|
||||
return engine
|
||||
|
||||
@@ -134,7 +134,8 @@
|
||||
"connect": {
|
||||
"success": "Connect success",
|
||||
"failed": "Connect failed"
|
||||
}
|
||||
},
|
||||
"timeout":"Timeout(second)"
|
||||
}
|
||||
},
|
||||
"chat": {
|
||||
|
||||
@@ -134,7 +134,8 @@
|
||||
"connect": {
|
||||
"success": "连接成功",
|
||||
"failed": "连接失败"
|
||||
}
|
||||
},
|
||||
"timeout":"查询超时(秒)"
|
||||
}
|
||||
},
|
||||
"chat": {
|
||||
|
||||
@@ -96,6 +96,9 @@
|
||||
<el-input v-model="form.dbSchema" />
|
||||
<el-button v-if="false" link type="primary" :icon="Plus">Get Schema</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('ds.form.timeout')" prop="timeout">
|
||||
<el-input-number v-model="form.timeout" :min="0" :max="300" controls-position="right" />
|
||||
</el-form-item>
|
||||
<span>
|
||||
<span>{{ t('ds.form.support_version') }}: </span>
|
||||
<span v-if="form.type === 'sqlServer'">2012+</span>
|
||||
@@ -211,6 +214,7 @@ const form = ref<any>({
|
||||
filename: '',
|
||||
sheets: [],
|
||||
mode: 'service_name',
|
||||
timeout: 30,
|
||||
})
|
||||
|
||||
const close = () => {
|
||||
@@ -246,6 +250,7 @@ const open = (item: any, editTable: boolean = false) => {
|
||||
form.value.filename = configuration.filename
|
||||
form.value.sheets = configuration.sheets
|
||||
form.value.mode = configuration.mode
|
||||
form.value.timeout = configuration.timeout ? configuration.timeout : 30
|
||||
}
|
||||
|
||||
if (editTable) {
|
||||
@@ -304,6 +309,7 @@ const open = (item: any, editTable: boolean = false) => {
|
||||
filename: '',
|
||||
sheets: [],
|
||||
mode: 'service_name',
|
||||
timeout: 30,
|
||||
}
|
||||
}
|
||||
dialogVisible.value = true
|
||||
@@ -363,6 +369,7 @@ const buildConf = () => {
|
||||
filename: form.value.filename,
|
||||
sheets: form.value.sheets,
|
||||
mode: form.value.mode,
|
||||
timeout: form.value.timeout,
|
||||
})
|
||||
)
|
||||
const obj = JSON.parse(JSON.stringify(form.value))
|
||||
@@ -377,6 +384,7 @@ const buildConf = () => {
|
||||
delete obj.filename
|
||||
delete obj.sheets
|
||||
delete obj.mode
|
||||
delete obj.timeout
|
||||
return obj
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user