//连接数据库
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'frer42dr4f@2134',
database:'caiji'
});
connection.connect();
//查询
connection.query('SELECT * from ss', function(err, rows, fields) {
if (err) throw err;
console.log('The solution is: ', rows);
});
connection.query("insert into ss(title,url) values('hello world', 'http://www.lejiaocn.com')", function(err, rows, fields) {
if (err) throw err;
console.log('The solution is: ', rows);
});
//关闭连接
connection.end();
nodejs调用mysql
最新推荐文章于 2023-01-07 12:57:18 发布