批量插入SQL node.js

时间:2018-06-28 16:39:04

标签: node.js bulkinsert

我发现了许多通过node.js批量插入SQL的示例,但是这些示例并没有成功。

app.post('/PostFile', middleware.requireAuthentication, function(req, res) {
  var token = req.get('auth') || '';
  var user = sessions.findSession(token);
  var sql1 = "insert into DW.table(TPermnum,LastName) VALUES ? ";
  var values = [
    ['145', 'Highway'],
    ['125', 'Lowstree'],
    ['14', 'Apple'],
    ['652', 'Mountain'],
    ['458', 'Valley'],
    ['45', 'Ocean'],
    ['52', 'Green'],
    ['48', 'Sky'],
    ['47', 'One'],
    ['02', 'Yellow'],
    ['5', 'Park '],
    ['52', 'Central '],
    ['47', 'Main'],
    ['89', 'Sideway ']
  ]
    if (user) {
      var connection = new sql.Connection(user.config, function(err) {
      var request = new sql.Request(connection);
        request.query(sql1, [values],
          function(err,result){
            if (err) throw err;
            console.log("Number of records inserted: " + result.affectedRows);
            });
});

我得到return typeof callback ===“ function”吗? callback(错误,_this.multiple?recordsets“ recordsets [0]):无效0;

TypeError:回调不是函数

非常感谢您的帮助。

0 个答案:

没有答案