var mysql = require (' mysql '); var pool = Mysql.createpool ({host: ' localhost ', User: ' Root ', Password:root, DA Tabase:demo, port:3306}), function Mysqlhelper () {};function querysql (Querysql, callback) {Pool.getconnection (func tion (err, conn) {//if (err) console.log ("POOL ==>" + err); if (err) {conn.release (); Return callback (ERR); } conn.query (Querysql, function (ERR2, rows) {//if (err) console.log (err); if (ERR2) {conn.release (); Return callback (ERR2); }//console.log ("select ==>"); Conn.release (); Callback (Err2,rows); }); });}; function ExecuteSQL (ExecuteSQL, callback) {pool.getconnection (function (ERR, conn) {//if (err) console.log ("PO OL ==> "+ err); if (err) {conn.release (); Return callback (ERR); } conn.query (ExecuteSQL, function (ERR2, res) {//if (err) console.log (err); if (ERR2) {conn.release (); Return callback (ERR2); }//console.log ("select ==>"); Conn.release (); Callback (Err2,res.affectedrows); }); });}; MySQLHelper.prototype.ExecuteSQL = ExecuteSQL; MySQLHelper.prototype.QuerySQL = Querysql;module.exports = Mysqlhelper;
Mysql,node.js