Standortplaner/db_check_potential.js

32 lines
923 B
JavaScript

const { Pool } = require('pg');
const pool = new Pool({
user: 'enwelo_admin',
host: '87.106.21.21',
database: 'enwelo',
password: 'WX1t1cgP1qK09',
port: 5432,
ssl: false
});
async function run() {
try {
const res = await pool.query("SELECT column_name, data_type FROM information_schema.columns WHERE table_schema = 'geodaten' AND table_name = 'potentialflächen_wind';");
console.log('Columns:', res.rows);
// Check if projekt_id exists in columns
const hasProjektId = res.rows.some(r => r.column_name === 'projekt_id');
if (hasProjektId) {
const dataRes = await pool.query('SELECT DISTINCT projekt_id FROM geodaten."potentialflächen_wind";');
console.log('Projects:', dataRes.rows);
} else {
console.log('No projekt_id column found.');
}
} catch(e) {
console.error('Fehler:', e);
} finally {
await pool.end();
}
}
run();