//使用连接池连接mysql
const mysql = require("mysql");
//创建连接池
    password:"123",
let pool = mysql.createPool({
    host:"127.0.0.1",
    post:"3306",
    user:"root",
    database:"school",
    connectionLimit:20  //设置连接池的大小
});
//执行SQL语句
//注意:连接池需要关闭连接
// pool.query("select * from student",(err,result)=>{
//     console.log(result);
// })
//删除编号为9的数据
pool.query("delete from student where sid = ?",[9],(err,result)=>{
    if(err)
        throw err;
    console.log(result);
})
posted on 2021-06-09 20:45  文种玉  阅读(263)  评论(0编辑  收藏  举报