MySQL CreateConnection Example
var mysqlClient = mysql.createConnection({ host : 'localhost', user : 'root', password : '', database : 'mydb' }); mysqlClient.connect(); mysqlClient.query( 'SELECT id,name,email FROM `cmf_users` WHERE id = ' + data.uid, function (error, results, fields) { console.log(results); });
MySQL PoolConnection Example
var mysqlPool = mysql.createPool({ connectionLimit : 10, host : 'localhost', user : 'root', password : '', database : 'mydb' }); mysqlPool.getConnection(function(err, mysqlConn) { mysqlConn.query( 'SELECT id,name,email FROM `cmf_users` WHERE id = ' + data.uid, function (error, results, fields) { console.log(results); } ) });