使用mssql连接Dataverse执行查询
const sql = require('mssql');
async function connectWithMssql() {
const config = {
server: 'xxx.com',
database: 'xxx15310',
port: 1433,
options: {
requestTimeout: 15000 * 10,
connectTimeout: 15000 * 10,
encrypt: true,
trustServerCertificate: false
},
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000
},
authentication: {
type: 'azure-active-directory-service-principal-secret',
options: {
clientId: 'xxx-001-001',
tenantId: 'xxx-aa046',
clientSecret: 'xxx-ww-r'
}
}
};
try {
const pool = await sql.connect(config);
const result = await pool.request()?.query(`select * from account`)
console.log(result)
return pool;
} catch (err) {
console.error('SQL连接错误:', err);
throw err;
}
}
connectWithMssql()