123456789101112131415161718192021222324252627 |
- var mysql=require("mysql");
- var pool = mysql.createPool({
- host: '127.0.0.1',
- user: 'lee',
- password: 'xiaohei!b22',
- database: 'ser_list',
- port: 3888,
- charset:'utf8mb4'
- });
- exports.query = function(sql,callback){
- pool.getConnection(function(err,conn){
- if(err){
- callback(err,null,null);
- }else{
- conn.query(sql,function(qerr,vals,fields){
- //释放连接
- conn.release();
- //事件驱动回调
- callback(qerr,vals,fields);
- });
- }
- });
- };
|