'use strict';
function doSQL(sql) {
let mysql = require('mysql');
let row = 'unfinished';
let connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'abcde1234',
database: 'user'
});
connection.connect();
connection.query(sql, function (err, rows) {
//这里总是在return之后执行
row=rows;
connection.end();
});
return row;// 返回 unfinished
}
module.exports=doSQL;
是不是应该用generator async 什么的?(要是有多种方法更好啦~ 谢谢
相关分类