var mysql = require('mysql');
//连接数据库
var connection = mysql.createConnection({
host: '替换成你自己的',
user: '替换成你自己的', //用户名
password: '替换成你自己的', //密码
database: '替换成你自己的',
port: '替换成你自己的' //端口号
});
connection.connect();
var delSql = 'DELETE FROM user WHERE user_name in(?)';
var delSqlParams = ['user1'];
//删
connection.query(delSql, delSqlParams, (err, result) => {
if (err) {
console.log('[DELETE ERROR] - ', err.message);
return;
}
console.log('--------------------------DELETE----------------------------');
console.log('DELETE affectedRows', result.affectedRows);
console.log('-----------------------------------------------------------------\n\n');
});
connection.end();
数据库: