2 回答
TA贡献2051条经验 获得超10个赞
var mysql = require('mysql');
var conn = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '',
database:'nodejs',
port: 3306
});
conn.connect();
//查询
// conn.query('SELECT * from user where name="wangzhiwei"', function(err, result) {
// if (err) throw err;
// console.log(result);
// })
//新增
// conn.query('insert into user (username,password) values("huxiaona","123456")', function(err, result) {
// if (err) throw err;
// console.log(result);
// })
//删除
// conn.query('delete from user where username="wupeigui"', function(err, result) {
// if (err) throw err;
// console.log(result);
// })
conn.query('update user set id="1" where username="huxiaona"',function(err,result){
if (err) {throw err};
console.log("修改数据成功");
})
conn.end();
- 2 回答
- 0 关注
- 575 浏览
添加回答
举报