Small fix for using mySQL Database backend. Switch mysql.CreateConnection to mysql.CreatePool.

This commit is contained in:
JSuenram 2022-01-21 15:14:10 +01:00
parent 9d023b8e09
commit 2ab250a10b

4
db.js
View File

@ -665,13 +665,13 @@ module.exports.CreateDB = function (parent, func) {
} else if (parent.args.mysql) {
// Use MySQL
obj.databaseType = 5;
var tempDatastore = require('mysql').createConnection(connectionObject);
var tempDatastore = require('mysql').createPool(connectionObject);
tempDatastore.query('CREATE DATABASE IF NOT EXISTS ' + dbname, function (error) {
if (error != null) {
console.log('Auto-create database failed: ' + error);
}
connectionObject.database = dbname;
Datastore = require('mysql').createConnection(connectionObject);
Datastore = require('mysql').createPool(connectionObject);
createTablesIfNotExist(dbname);
});
setTimeout(function () { tempDatastore.end(); }, 2000);