我是 nodejs 和 mysql 的新手。我想使用 nodejs 将一些数据插入 mysql 数据库。我曾尝试使用和不使用 mysql-crud 模块进行此操作,但我失败了。任何人都可以帮助我吗?
exports.insertquotereq = function(req, res){
var chat_data = {
to_country: req.whereto,
to_airport: req.toairport,
from_country: req.fromwhere,
from_airport: req.fromairport,
planetype: req.planetype,
startdate: req.startdate,
starttime: req.starttime,
returndate: req.returndate,
returntime: req.returndate,
email: req.email,
distance: req.distance,
estimatedhrs: req.estimatedhrs,
planecostperhr: req.planecostperhr,
estimatedcost: req.estimatedcost,
estimated_time: req.estimated_time
};
//console.log('chat_data',chat_data);
var insert = connection.query("INSERT INTO chat SET ?", chat_data, function(err, result){
if(err) throw err;
console.log('data inserted'+insert);
});
};