fix: 修改文件名大小写

This commit is contained in:
2025-04-24 12:03:19 +08:00
parent 2d46b89d28
commit 9db06fa737
7 changed files with 1095 additions and 27 deletions

View File

@@ -0,0 +1,35 @@
const mysql = require('mysql');
const { cdkDbConfig } = require('../config/db.config');
// 创建连接池
const pool = mysql.createPool(cdkDbConfig);
// 获取数据库连接
exports.getConnection = () => {
return new Promise((resolve, reject) => {
pool.getConnection((err, connection) => {
if (err) {
reject(err);
} else {
resolve(connection);
}
});
});
};
// 执行查询
exports.query = async (sql, values = [], connection) => {
if (!connection) {
connection = await exports.getConnection();
}
return new Promise((resolve, reject) => {
connection.query(sql, values, (err, results) => {
connection.release(); // 释放连接
if (err) {
reject(err);
} else {
resolve(results);
}
});
});
};