1
0
Code Issues Pull Requests Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
程序员小墨 2022-09-30 00:52:56 +08:00
parent 5b31b4bf98
commit 08f303de8f
3 changed files with 9 additions and 5 deletions

View File

@ -0,0 +1,2 @@
const dbUtils = require('./utils/dbUtils');
const dbPoolUtils = require('./utils/dbPoolUtils');

View File

@ -80,6 +80,7 @@ function close() {
}
module.exports = {
createPool: createPool,
query: query,
close: close,
}

View File

@ -4,13 +4,14 @@ const fs = require('fs');
const path = require('path');
let globalConfig = JSON.parse(fs.readFileSync(path.join(__dirname, '../config.json'), 'utf8'));
let config = {
...globalConfig.mysql,
};
console.log(config);
async function query(sql) {
//通过MySQL中方法创建链接对象
let config = {
...globalConfig.mysql,
};
console.log(config);
//通过MySQL中方法创建连接对象
var connection = mysql.createConnection(config);
//开始连接
connection.connect();