我在执行更新查询时遇到问题。现在它在select查询中运行正常,更新查询很好,因为我可以从输出复制粘贴单个更新查询,它将相应地更新。抛出没有错误,出现带有更新字符串的流但不执行任何错误。
connection.connect();
connection.query('SELECT text, id from twits2 order by id ASC', function(err, rows) {
rows.forEach(function(row){
var id = row.id;
var r1 = sentiment(row.text);
var score = r1.score;
var comparative = r1.comparative;
var q = 'UPDATE twits2 SET score ="'+score+'", comparative ="'+comparative+'" WHERE id="'+id+'"';
console.log(q);
connection.query(q, function (error, results, fields) {
if (error) throw error;
});
});