diff --git a/backend/apps/datasource/models/datasource.py b/backend/apps/datasource/models/datasource.py
index 55742f7b..f84aa691 100644
--- a/backend/apps/datasource/models/datasource.py
+++ b/backend/apps/datasource/models/datasource.py
@@ -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
}
diff --git a/backend/apps/db/db.py b/backend/apps/db/db.py
index d1fa5ab0..d096eeb3 100644
--- a/backend/apps/db/db.py
+++ b/backend/apps/db/db.py
@@ -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
diff --git a/backend/apps/db/engine.py b/backend/apps/db/engine.py
index 4bfc7b54..64cdc79f 100644
--- a/backend/apps/db/engine.py
+++ b/backend/apps/db/engine.py
@@ -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)
def get_engine_uri(conf: DatasourceConf):
diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json
index fb861a93..7220de58 100644
--- a/frontend/src/i18n/en.json
+++ b/frontend/src/i18n/en.json
@@ -134,7 +134,8 @@
"connect": {
"success": "Connect success",
"failed": "Connect failed"
- }
+ },
+ "timeout":"Timeout(second)"
}
},
"chat": {
diff --git a/frontend/src/i18n/zh-CN.json b/frontend/src/i18n/zh-CN.json
index bcb03dba..c4321944 100644
--- a/frontend/src/i18n/zh-CN.json
+++ b/frontend/src/i18n/zh-CN.json
@@ -134,7 +134,8 @@
"connect": {
"success": "连接成功",
"failed": "连接失败"
- }
+ },
+ "timeout":"查询超时(秒)"
}
},
"chat": {
diff --git a/frontend/src/views/ds/form.vue b/frontend/src/views/ds/form.vue
index a49a4c38..88e6c12d 100644
--- a/frontend/src/views/ds/form.vue
+++ b/frontend/src/views/ds/form.vue
@@ -96,6 +96,9 @@
Get Schema
+
+
+
{{ t('ds.form.support_version') }}:
2012+
@@ -211,6 +214,7 @@ const form = ref({
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
}