-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-db.js
37 lines (29 loc) · 1.08 KB
/
test-db.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import mysql from 'mysql2/promise';
async function testConnection() {
try {
const connection = await mysql.createConnection({
host: '187.103.249.49',
port: 3306,
user: 'root',
password: 'bk134',
database: 'radius'
});
console.log('Successfully connected to the database');
// Test query to check table structure
const [tables] = await connection.execute('SHOW TABLES');
console.log('\nAvailable tables:', tables);
// Test query to check radacct table
const [columns] = await connection.execute('SHOW COLUMNS FROM radacct');
console.log('\nradacct table structure:', columns);
// Test query to get a sample record
const [records] = await connection.execute('SELECT * FROM radacct LIMIT 1');
console.log('\nSample record:', records);
// Get total count
const [count] = await connection.execute('SELECT COUNT(*) as total FROM radacct');
console.log('\nTotal records in radacct:', count[0].total);
await connection.end();
} catch (error) {
console.error('Error:', error);
}
}
testConnection();