Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用mysljs在mySql和node.js中大容量插入_Mysql_Node.js_Bluebird - Fatal编程技术网

如何使用mysljs在mySql和node.js中大容量插入

如何使用mysljs在mySql和node.js中大容量插入,mysql,node.js,bluebird,Mysql,Node.js,Bluebird,我无法使用node.js lib在我的数据库中使用大容量插入 我遵循了以下答案: 没有成功 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', '.

我无法使用node.js lib在我的数据库中使用大容量插入

我遵循了以下答案:

没有成功

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' 

我还尝试使用bluebird提示查询方法,但没有成功,我再次遇到了相同的错误。

尝试删除
值周围的方括号。

您需要用严重重音(backtick)字符标记键,如下所示:`key>`

使您的
查询
如下所示:

var sql = "INSERT INTO resources (`resource_container_id`, `name`, `title`, `extension`, `mime_type`, `size`) VALUES ?";
尝试在问号周围使用()


var sql=“插入资源(资源容器id、名称、标题、扩展名、mime类型、大小)值(?)

我只有在使用
connection.execute()
时才会遇到同样的问题,实际上这是因为它不是为准备好的语句实现的

我通过使用
connection.query()
解决了这个问题

我不知道这个答案是否有帮助


当我搜索答案时,它会帮助我。

值周围的方括号
意味着ArrayDoe对我不起作用,仍然会出错。我与mysql2库有相同的问题,也不起作用。回调中应该有
(err,result)=>{…}
,但这可能不是您在这里描述的错误,因为错误实际上是在某个点打印的,所以我假设它只是一个复制错误。