功能:一次插入多条数据;
参考:https://www.jianshu.com/p/62a9d2340c56
github:https://github.com/mysqljs/mysql
代码
var mysql = require('mysql'); var connection = mysql.createConnection({ host : '127.0.0.1', user : 'root', password : 'root', database : 'kg-hanyu' }); connection.connect(); // connection.query('SELECT * from word', function (error, results, fields) { // if (error) throw error; // console.log('The solution is: ', results); // }); var post = [[4, '吗', 3, 0],[5, '吗', 3, 0]]; connection.query('INSERT INTO word VALUES ?', [post], function (error, results, fields) { if (error) throw error; }); connection.end();