mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
refactor: sql server support selecting compatibility with lower versions
This commit is contained in:
@@ -120,6 +120,7 @@ class DatasourceConf(BaseModel):
|
||||
sheets: List = ''
|
||||
mode: str = ''
|
||||
timeout: int = 30
|
||||
lowVersion: bool = False
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
@@ -134,7 +135,8 @@ class DatasourceConf(BaseModel):
|
||||
"filename": self.filename,
|
||||
"sheets": self.sheets,
|
||||
"mode": self.mode,
|
||||
"timeout": self.timeout
|
||||
"timeout": self.timeout,
|
||||
"lowVersion": self.lowVersion
|
||||
}
|
||||
|
||||
|
||||
|
||||
+22
-10
@@ -108,16 +108,28 @@ def get_extra_config(conf: DatasourceConf):
|
||||
def get_origin_connect(type: str, conf: DatasourceConf):
|
||||
extra_config_dict = get_extra_config(conf)
|
||||
if equals_ignore_case(type, "sqlServer"):
|
||||
return pymssql.connect(
|
||||
server=conf.host,
|
||||
port=str(conf.port),
|
||||
user=conf.username,
|
||||
password=conf.password,
|
||||
database=conf.database,
|
||||
timeout=conf.timeout,
|
||||
tds_version='7.0', # options: '4.2', '7.0', '8.0' ...,
|
||||
**extra_config_dict
|
||||
)
|
||||
# none or true, set tds_version = 7.0
|
||||
if conf.lowVersion is None or conf.lowVersion:
|
||||
return pymssql.connect(
|
||||
server=conf.host,
|
||||
port=str(conf.port),
|
||||
user=conf.username,
|
||||
password=conf.password,
|
||||
database=conf.database,
|
||||
timeout=conf.timeout,
|
||||
tds_version='7.0', # options: '4.2', '7.0', '8.0' ...,
|
||||
**extra_config_dict
|
||||
)
|
||||
else:
|
||||
return pymssql.connect(
|
||||
server=conf.host,
|
||||
port=str(conf.port),
|
||||
user=conf.username,
|
||||
password=conf.password,
|
||||
database=conf.database,
|
||||
timeout=conf.timeout,
|
||||
**extra_config_dict
|
||||
)
|
||||
|
||||
|
||||
# use sqlalchemy
|
||||
|
||||
@@ -348,7 +348,8 @@
|
||||
"failed": "Connect failed"
|
||||
},
|
||||
"timeout": "Timeout(second)",
|
||||
"address": "Address"
|
||||
"address": "Address",
|
||||
"low_version": "Compatible with lower versions"
|
||||
},
|
||||
"sync_fields": "Sync Fields"
|
||||
},
|
||||
|
||||
@@ -348,7 +348,8 @@
|
||||
"failed": "연결 실패"
|
||||
},
|
||||
"timeout": "쿼리 시간 초과(초)",
|
||||
"address": "주소"
|
||||
"address": "주소",
|
||||
"low_version": "낮은 버전 호환"
|
||||
},
|
||||
"sync_fields": "동기화된 테이블 구조"
|
||||
},
|
||||
|
||||
@@ -348,7 +348,8 @@
|
||||
"failed": "连接失败"
|
||||
},
|
||||
"timeout": "查询超时(秒)",
|
||||
"address": "地址"
|
||||
"address": "地址",
|
||||
"low_version": "兼容低版本"
|
||||
},
|
||||
"sync_fields": "同步表结构"
|
||||
},
|
||||
|
||||
@@ -116,6 +116,7 @@ const form = ref<any>({
|
||||
sheets: [],
|
||||
mode: 'service_name',
|
||||
timeout: 30,
|
||||
lowVersion: false,
|
||||
})
|
||||
|
||||
const close = () => {
|
||||
@@ -159,6 +160,10 @@ const initForm = (item: any, editTable: boolean = false) => {
|
||||
form.value.sheets = configuration.sheets
|
||||
form.value.mode = configuration.mode
|
||||
form.value.timeout = configuration.timeout ? configuration.timeout : 30
|
||||
form.value.lowVersion =
|
||||
configuration.lowVersion !== null && configuration.lowVersion !== undefined
|
||||
? configuration.lowVersion
|
||||
: true
|
||||
}
|
||||
|
||||
if (editTable) {
|
||||
@@ -230,6 +235,7 @@ const initForm = (item: any, editTable: boolean = false) => {
|
||||
sheets: [],
|
||||
mode: 'service_name',
|
||||
timeout: 30,
|
||||
lowVersion: false,
|
||||
}
|
||||
}
|
||||
dialogVisible.value = true
|
||||
@@ -317,6 +323,7 @@ const buildConf = () => {
|
||||
sheets: form.value.sheets,
|
||||
mode: form.value.mode,
|
||||
timeout: form.value.timeout,
|
||||
lowVersion: form.value.lowVersion,
|
||||
})
|
||||
)
|
||||
const obj = JSON.parse(JSON.stringify(form.value))
|
||||
@@ -332,6 +339,7 @@ const buildConf = () => {
|
||||
delete obj.sheets
|
||||
delete obj.mode
|
||||
delete obj.timeout
|
||||
delete obj.lowVersion
|
||||
return obj
|
||||
}
|
||||
|
||||
@@ -671,6 +679,13 @@ defineExpose({
|
||||
<el-radio value="sid">{{ t('ds.form.mode.sid') }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="form.type === 'sqlServer'"
|
||||
:label="t('ds.form.low_version')"
|
||||
prop="low_version"
|
||||
>
|
||||
<el-checkbox v-model="form.lowVersion" :label="t('ds.form.low_version')" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.type !== 'es'" :label="t('ds.form.extra_jdbc')">
|
||||
<el-input
|
||||
v-model="form.extraJdbc"
|
||||
|
||||
Reference in New Issue
Block a user