Skip to content

数据库连接支持达梦数据库 #4368

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"mysql2": "^3.11.3",
"json5": "^2.2.3",
"pg": "^8.10.0",
"wikijs": "^6.4.1"
"wikijs": "^6.4.1",
"dmdb":"^1.0.0"
},
"devDependencies": {
"@fastgpt/global": "workspace:*",
Expand Down
13 changes: 12 additions & 1 deletion packages/plugins/src/databaseConnection/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Client as PgClient } from 'pg'; // PostgreSQL 客户端
import mysql from 'mysql2/promise'; // MySQL 客户端
import mssql from 'mssql'; // SQL Server 客户端

import dmdb from 'dmdb'; //达梦数据库
type Props = {
databaseType: string;
host: string;
Expand Down Expand Up @@ -67,6 +67,17 @@ const main = async ({

result = await pool.query(sql);
await pool.close();
}else if ( databaseType === 'dmdb' ){
const connInfo = {
connectString: `${host}:${parseInt(port, 10)}`,
user: user,
password: password,
loginEncrypt: false,
ignoreCase: true
}
const connection = await dmdb.getConnection(connInfo)
result = await connection.execute(sql);
await connection.close();
}
return {
result
Expand Down
4 changes: 4 additions & 0 deletions packages/plugins/src/databaseConnection/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
{
"label": "Microsoft SQL Server",
"value": "Microsoft SQL Server"
},
{
"label": "dmdb",
"value": "dmdb"
}
],
"required": true
Expand Down
4 changes: 3 additions & 1 deletion projects/app/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ CHECK_INTERNAL_IP=false
# # 日志来源ID前缀
# CHAT_LOG_SOURCE_ID_PREFIX=fastgpt-
# 自定义跨域,不配置时,默认都允许跨域(逗号分割)
ALLOWED_ORIGINS=
ALLOWED_ORIGINS=
# 允许使用旧版加密算法 (达梦数据库连接时需要)
NODE_OPTIONS=--openssl-legacy-provider