Standortplaner/query_db_temp.js

25 lines
711 B
JavaScript

require('dotenv').config();
const { Client } = require('pg');
const client = new Client({
user: process.env.DB_USER,
host: process.env.DB_HOST,
database: process.env.DB_NAME,
password: process.env.DB_PASSWORD,
port: process.env.DB_PORT
});
client.connect().then(async () => {
// Show tables
const res = await client.query('SELECT table_name FROM information_schema.tables WHERE table_schema = $1', ['geodaten']);
console.log('Tables:', res.rows.map(r => r.table_name));
// Get projects
const projRes = await client.query('SELECT * FROM geodaten.projekte');
console.log('Projekte:', projRes.rows);
await client.end();
}).catch(e => {
console.error(e);
});