如何使用mysljs在mySql和node.js中批量插入
我不能够使用node.js lib mysljs在我的数据库中使用批量插入。
我遵循以下答案:
如何使用node.js在mySQL中进行批量插入
没有成功。
var sql = "INSERT INTO resources (resource_container_id, name, title, extension, mime_type, size) VALUES ?"; var values = [ [1, 'pic1', 'title1', '.png', 'image/png', 500], [1, 'pic2', 'title2', '.png', 'image/png', 700]]; return connection.query(sql, [values], (result) => { if (err) throw err; connection.end(); });
我不断收到错误:
'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \'?\' at line 1'
我也尝试使用蓝鸟promisify查询mehod,但没有成功,我再次得到同样的错误。
尝试删除values
的方括号