var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '',
database: 'test',
port: '3306'
});
connection.connect();
var userInfo = null;
connection.query("select * from user", function (err, items) {
if (err) console.log(err);
console.log(items);
});
var item = {id: 2, name: 'gc', desc: 'haha'};
connection.query("insert into user set ?", item, function (err, result) {
console.log(result + '\n');
});
connection.end();
增删改查都可以做到.
网友评论