const mysql = require("mysql");
const config = {
host:'127.0.0.1',
user:'root',
password:'',
database : "test",
connectionLimit : 10
}
const pool = mysql.createPool(config);
let strQuery = 'SELECT * FROM `test`';
//①getConnectionからqueryを実行
pool.getConnection(function(err,conn){
if(err) throw err;
conn.query(strQuery,function(error,results,fields){
if(error) throw error;
console.log(results);
conn.release();
});
});
//②直接queryを実行
pool.query(strQuery,function(error,results,fields){
if(error) throw error;
console.log(results);
});
この二つのクエリの挙動は内部ではどう違うのでしょうか?