feat: 新增 nodejs 实验 8

This commit is contained in:
2025-12-09 11:08:15 +08:00
parent 11b4998dca
commit ad1a6a22e9
8 changed files with 535 additions and 0 deletions

24
Server/tests/test8/db.js Normal file
View File

@@ -0,0 +1,24 @@
const mysql = require("mysql2/promise")
let pool;
const connect = async () => {
if (!pool) {
pool = mysql.createPool({
host: "localhost",
user: "root",
password: "123456",
database: "express_db"
})
}
console.log("database is connect");
return pool;
}
module.exports = {
connect,
query: async (sql, values) => {
const pool = await connect();
return pool.query(sql, values);
}
}