Select Git revision
2023_04_06_032422_user.php
db.js 655 B
const mysql = require("mysql2/promise")
// Create connection pool
const pool = mysql.createPool({
host: process.env.DB_HOST || "localhost",
user: process.env.DB_USER || "root",
password: process.env.DB_PASSWORD || "",
database: process.env.DB_NAME || "test_dashboard3",
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
})
// Test connection
async function testConnection() {
try {
const connection = await pool.getConnection()
console.log("Connected to database")
connection.release()
} catch (err) {
console.error("Database connection error: " + err.stack)
}
}
testConnection()
module.exports = pool