sql语法错误'检查与您的MySQL服务器版本相对应的手册,以找到在第1行的''附近使用的正确语法'

时间:2019-05-06 09:56:38

标签: mysql node.js

任何人都可以帮助我,我在这里遇到错误。我将对象传递给sql。我对sql很新。我在这里做错了什么。您可以看到我通过的对象enter code here

    hashtag: 'sololuxuryindia',
  username: 'shallweslay',
  image_url:
   'https://instagram.fktm8-1.fna.fbcdn.net/vp/99c949ff0fa6e81dacf73b7cd6c0204c/5D5699CB/t51.2885-15/e35/37890602_230278911161214_3971639108530339840_n.jpg?_nc_ht=instagram.fktm8-1.fna.fbcdn.net',
  description:
   'No such thing as too much Gucci!  You can buy these and so many more other brands on',
  comments: [] }

这是查询

let sql = 'INSERT INTO hash_tags SET ?'
        let query = db.query(sql, post, (err, result) => {
            if (err) console.log(err);
            else console.log('post added');
        })

帖子是我正在传递的对象(上方)

{ 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 '' at line 1 at Query.Sequence._packetToError (D:\Desktop\scraper_nodejs\node_modules\mysql\lib\protocol\sequences\Sequence.js:47:14) at Query.ErrorPacket (D:\Desktop\scraper_nodejs\node_modules\mysql\lib\protocol\sequences\Query.js:77:18) at Protocol._parsePacket (D:\Desktop\scraper_nodejs\node_modules\mysql\lib\protocol\Protocol.js:291:23) at Parser._parsePacket (D:\Desktop\scraper_nodejs\node_modules\mysql\lib\protocol\Parser.js:433:10) at Parser.write (D:\Desktop\scraper_nodejs\node_modules\mysql\lib\protocol\Parser.js:43:10) at Protocol.write (D:\Desktop\scraper_nodejs\node_modules\mysql\lib\protocol\Protocol.js:38:16) at Socket.<anonymous> (D:\Desktop\scraper_nodejs\node_modules\mysql\lib\Connection.js:91:28) at Socket.<anonymous> (D:\Desktop\scraper_nodejs\node_modules\mysql\lib\Connection.js:525:10) at Socket.emit (events.js:189:13) at addChunk (_stream_readable.js:284:12) -------------------- at Protocol._enqueue (D:\Desktop\scraper_nodejs\node_modules\mysql\lib\protocol\Protocol.js:144:48) at Connection.query (D:\Desktop\scraper_nodejs\node_modules\mysql\lib\Connection.js:201:25) at resolve (D:\Desktop\scraper_nodejs\commands\instacommentscrapper.js:142:28) at new Promise (<anonymous>) at Object.sendToDb (D:\Desktop\scraper_nodejs\commands\instacommentscrapper.js:138:16) at Promise (D:\Desktop\scraper_nodejs\commands\instacommentscrapper.js:125:32) at process._tickCallback (internal/process/next_tick.js:68:7) code: 'ER_PARSE_ERROR', errno: 1064, sqlMessage: '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 \'\' at line 1', sqlState: '42000', index: 0, sql: 'INSERT INTO hash_tags SET标签= \'sololuxuryindia\',用户名= \'shallweslay\',图像_URL = \'https://instagram.fktm8-1.fna.fbcdn.net/vp/99c949ff0fa6e81dacf73b7cd6c0204c/5D5699CB/t51.2885-15/e35/37890602_230278911161214_3971639108530339840_n.jpg?_nc_ht=instagram.fktm8-1.fna.fbcdn.net\',描述= \'No such thing as too much Gucci! You can buy these and so many more other brands on\',评论= ' }

0 个答案:

没有答案