Fixed MySQL monitor to close connection

Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>
This commit is contained in:
Matthew Nickson 2022-11-17 18:34:02 +00:00
parent f9be918246
commit b053bc61ce
No known key found for this signature in database
GPG Key ID: BF229DCFD4748E05
1 changed files with 6 additions and 6 deletions

View File

@ -13,7 +13,7 @@ const { badgeConstants } = require("./config");
const mssql = require("mssql");
const { Client } = require("pg");
const postgresConParse = require("pg-connection-string").parse;
const mysql = require("mysql2/promise");
const mysql = require("mysql2");
const { NtlmClient } = require("axios-ntlm");
const { Settings } = require("./settings");
const radiusClient = require("node-radius-client");
@ -300,16 +300,16 @@ exports.postgresQuery = function (connectionString, query) {
*/
exports.mysqlQuery = function (connectionString, query) {
return new Promise((resolve, reject) => {
return mysql.createConnection(connectionString)
.then(connection => {
connection.connect();
return connection.query(query);
})
const connection = mysql.createConnection(connectionString);
connection.promise().query(query)
.then(res => {
resolve(res);
})
.catch(err => {
reject(err);
})
.finally(() => {
connection.end();
});
});
};