Skip to content

Commit 47ffe65

Browse files
committed
数据库连接支持达梦数据库
1 parent f483832 commit 47ffe65

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

packages/plugins/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"mysql2": "^3.11.3",
1515
"json5": "^2.2.3",
1616
"pg": "^8.10.0",
17-
"wikijs": "^6.4.1"
17+
"wikijs": "^6.4.1",
18+
"dmdb":"^1.0.0"
1819
},
1920
"devDependencies": {
2021
"@fastgpt/global": "workspace:*",

packages/plugins/src/databaseConnection/index.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Client as PgClient } from 'pg'; // PostgreSQL 客户端
22
import mysql from 'mysql2/promise'; // MySQL 客户端
33
import mssql from 'mssql'; // SQL Server 客户端
4-
4+
import dmdb from 'dmdb'; //达梦数据库
55
type Props = {
66
databaseType: string;
77
host: string;
@@ -67,6 +67,17 @@ const main = async ({
6767

6868
result = await pool.query(sql);
6969
await pool.close();
70+
}else if ( databaseType === 'dmdb' ){
71+
const connInfo = {
72+
connectString: `${host}:${parseInt(port, 10)}`,
73+
user: user,
74+
password: password,
75+
loginEncrypt: false,
76+
ignoreCase: true
77+
}
78+
const connection = await dmdb.getConnection(connInfo)
79+
result = await connection.execute(sql);
80+
await connection.close();
7081
}
7182
return {
7283
result

packages/plugins/src/databaseConnection/template.json

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
{
4747
"label": "Microsoft SQL Server",
4848
"value": "Microsoft SQL Server"
49+
},
50+
{
51+
"label": "dmdb",
52+
"value": "dmdb"
4953
}
5054
],
5155
"required": true

projects/app/.env.template

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,6 @@ CHECK_INTERNAL_IP=false
6363
# # 日志来源ID前缀
6464
# CHAT_LOG_SOURCE_ID_PREFIX=fastgpt-
6565
# 自定义跨域,不配置时,默认都允许跨域(逗号分割)
66-
ALLOWED_ORIGINS=
66+
ALLOWED_ORIGINS=
67+
# 允许使用旧版加密算法 (达梦数据库连接时需要)
68+
NODE_OPTIONS=--openssl-legacy-provider

0 commit comments

Comments
 (0)