Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.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
Mysql SQL语法,nodejs sequalize,一次多行_Mysql_Node.js - Fatal编程技术网

Mysql SQL语法,nodejs sequalize,一次多行

Mysql SQL语法,nodejs sequalize,一次多行,mysql,node.js,Mysql,Node.js,我试图在启动时用虚拟数据填充mysql数据库,但我一直遇到这个werid问题 Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO Teachers 我试着检查一下语法是否正确,大多数在线检查人员都告诉我这没

我试图在启动时用虚拟数据填充mysql数据库,但我一直遇到这个werid问题

Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the 
manual that corresponds to your MySQL server version for the right 
syntax to use near 'INSERT INTO Teachers
我试着检查一下语法是否正确,大多数在线检查人员都告诉我这没有错。尽管如此,它还是给了我这个错误。但是,如果我尝试通过mysql workbench查询数据库,它工作得很好,插入数据没有任何问题

const mysql = require('mysql')
const config = require('./config')

var con = mysql.createConnection({
  host: config.db.options.host,
  user: config.db.user,
  password: config.db.password
})
let superScript = `
  USE school;
 INSERT INTO Teachers
    (FirstName,LastName,Gender,Address,PhoneNumber,Email ,Facebook_ID                 
   ,Qualification, Good_at,Personal_Description,Teachering_Experience,Music_skill,Language_skill,Image_URL) 
  VALUES("Glennys","Looker","Male","125 Melbourne street", 
  "1234567890","abc123@gmail.com"
    ,"GlennysFB","Master","Piano"
    ,"I am a pianist and composer who has taught people of all ages   and levels, including absolute beginners, adult students, and taking     students through AMEB or VCE exams. "
    ," 7 Years Teaching Experience","Piano","English,Japanese"
    ,"https://segundadivisionweb.files.wordpress.com/2017/04/profesor-    de-musica.jpg");`;


 function createDB () {
  con.connect(function (err) {
    if (err) throw err
console.log('Connected!')
con.query(`CREATE DATABASE IF NOT EXISTS ${config.db.database}`, 
 function (err, result) {
  if (err) throw err
  console.log('Database created')
})
con.query(superScript, function (err, result) {
    if (err) throw err;
    console.log("1 record inserted");
    });




  })
}

我应该怎么做才能插入这些数据呢?

不是程序员,但您不能在一个语句中发出多个语句

像这样尝试(不带USE语句):


或者将数据库放入您的连接设置中。

如果有人遇到同样的问题,下面是解决方案

  var con = mysql.createConnection({
    host: config.db.options.host,
    user: config.db.user,
    password: config.db.password,
    database: config.db.database,
    multipleStatements: true
  })
这将允许u在一个字符串中插入任意多的元素

  var con = mysql.createConnection({
    host: config.db.options.host,
    user: config.db.user,
    password: config.db.password,
    database: config.db.database,
    multipleStatements: true
  })