All checks were successful
Docker Build and Push / build-image (push) Successful in 3m16s
23 lines
865 B
JavaScript
23 lines
865 B
JavaScript
require('dotenv').config();
|
|
const mysql = require('mysql2/promise');
|
|
|
|
(async () => {
|
|
const url = new URL(process.env.DATABASE_URL);
|
|
const conn = await mysql.createConnection({
|
|
host: url.hostname,
|
|
port: Number(url.port),
|
|
user: decodeURIComponent(url.username),
|
|
password: decodeURIComponent(url.password),
|
|
database: url.pathname.replace(/^\//, ''),
|
|
});
|
|
const [tables] = await conn.query('SHOW TABLES');
|
|
console.log('TABLES:');
|
|
for (const row of tables) console.log(' -', Object.values(row)[0]);
|
|
const tableNames = ['User', 'Article', 'Strategy', 'Indicator', 'Econ_SowInventory'];
|
|
for (const t of tableNames) {
|
|
const [r] = await conn.query('SELECT COUNT(*) AS c FROM ' + t + '');
|
|
console.log(t + ': ' + r[0].c + ' rows');
|
|
}
|
|
await conn.end();
|
|
})().catch((e) => { console.error('ERR:', e.message); process.exit(1); });
|