我想通过node.js mysql模块将多行插入到mysql中。我的数据是通过node.js将多行插入到mysql
var data = [{'test':'test1'},{'test':'test2'}];
我使用游泳池
pool.getConnection(function(err, connection) {
connection.query('INSERT INTO '+TABLE+' SET ?', data, function(err, result) {
if (err) throw err;
else {
console.log('successfully added to DB');
connection.release();
}
});
});
}
其失败。
有没有办法让我有一个批量插入和所有插入完成后调用一个函数?
问候 锤
可能的重复[如何在mySQL中使用node.js批量插入](http://stackoverflow.com/questions/8899802/how-do-i-do-a-bulk-ins ert-in-mysql-using-node-js) –