25 lines
720 B
JavaScript
25 lines
720 B
JavaScript
const { Pool } = require('pg');
|
|
require('dotenv').config();
|
|
|
|
const pool = new Pool({
|
|
host: process.env.DB_HOST,
|
|
port: parseInt(process.env.DB_PORT),
|
|
user: process.env.DB_USER,
|
|
password: process.env.DB_PASSWORD,
|
|
database: process.env.DB_NAME,
|
|
});
|
|
|
|
async function listAllTables() {
|
|
try {
|
|
const res = await pool.query("SELECT table_schema, table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema NOT IN ('information_schema', 'pg_catalog')");
|
|
console.log("All tables:");
|
|
res.rows.forEach(row => console.log(`- ${row.table_schema}.${row.table_name}`));
|
|
} catch (err) {
|
|
console.error("Error:", err);
|
|
} finally {
|
|
await pool.end();
|
|
}
|
|
}
|
|
|
|
listAllTables();
|