firt commit
This commit is contained in:
commit
c2e63830e1
71 changed files with 9613 additions and 0 deletions
29
server/utils/database.js
Executable file
29
server/utils/database.js
Executable file
|
@ -0,0 +1,29 @@
|
|||
import mariadb from 'mariadb';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
// Create a pool without database selection first
|
||||
const initialPool = mariadb.createPool({
|
||||
host: '172.10.1.4', // Remote database host
|
||||
user: 'handball', // Remote database user
|
||||
password: 'Gabi2104@', // Remote database password
|
||||
database: 'handball', // Database name
|
||||
connectionLimit: 5
|
||||
});
|
||||
|
||||
export const pool = initialPool;
|
||||
|
||||
export async function query(sql, params) {
|
||||
let conn;
|
||||
try {
|
||||
conn = await pool.getConnection();
|
||||
const result = await conn.query(sql, params);
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('Database query error:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
if (conn) conn.release();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue