feat: support mssql in databaseConnection plugin (#3674)

* feat: support mssql in databaseConnection plugin

* feat: trust server certificate for mssql
This commit is contained in:
Ge
2025-02-01 10:53:20 +08:00
committed by GitHub
parent 16629e32a7
commit c393002f1d
4 changed files with 388 additions and 23 deletions

View File

@@ -1,5 +1,6 @@
import { Client as PgClient } from 'pg'; // PostgreSQL 客户端
import mysql from 'mysql2/promise'; // MySQL 客户端
import mssql from 'mssql'; // SQL Server 客户端
type Props = {
databaseType: string;
@@ -52,6 +53,20 @@ const main = async ({
const [rows] = await connection.execute(sql);
result = rows;
await connection.end();
} else if (databaseType === 'Microsoft SQL Server') {
const pool = await mssql.connect({
server: host,
port: parseInt(port, 10),
database: databaseName,
user,
password,
options: {
trustServerCertificate: true
}
});
result = await pool.query(sql);
await pool.close();
}
return {
result

View File

@@ -42,6 +42,10 @@
{
"label": "PostgreSQL",
"value": "PostgreSQL"
},
{
"label": "Microsoft SQL Server",
"value": "Microsoft SQL Server"
}
],
"required": true