问题描述
尝试在sql中查看该行
INSERT INTO eu_profile (id,profileName) VALUES ?
import * as MysqL2 from 'MysqL2';
import * from 'MysqL2/promise'
/** Lets open the database for MysqL2 */
const MysqL2connection = MysqL2.createConnection({
"host": "localhost","port": 3306,"user": "node","password": "NottellingYou","database": "stats"
});
MysqL2connection.connect(function(error){
if(!!error){
console.log(error);
}else{
console.log('Connected!:)');
}
});
let dbTables: string="";
let sqlInsert: string="";
dbTables = "id,profileName";
sqlInsert = "INSERT INTO eu_profile ("+dbTables+") VALUES ?"
const profileLoad = await MysqL2connection.query(sqlInsert,[profileData],function(err) {
if (err) throw err{
MysqL2connection.end();
}else
}).then(console.log("We are done here"));
解决方法
如果您有两列,则需要tiw值
INSERT INTO eu_profile (id,profileName) VALUES (?,?)
另外[profileData]
需要2个值,例如[req.body.topic,req.body.note]