mysql2文档
https://github.com/sidorares/node-mysql2
const mysql = require('mysql2')
//创建连接
const connection = mysql.createConnection({
host: 'localhost',
port: '3306',
database: 'coderhub',
user: 'root',
password: 'root123.'
})
//编写SQL语句
const statement = `SELECT * FROM products WHERE price > 6000; `
//查询
connection.query(statement, (err,results, fields) => {
console.log(results)
})
执行结果:
image.png
网友评论