const { Client } = require('pg');

async function inspect() {
    require('dotenv').config({ path: '../.env' });
const client = new Client({
    host: process.env.DB_HOST,
    port: process.env.DB_PORT,
    user: process.env.DB_USER,
    password: process.env.DB_PASSWORD,
    database: process.env.DB_NAME
});
    
    try {
        await client.connect();
        const res = await client.query(`
            SELECT column_name, data_type, is_nullable
            FROM information_schema.columns
            WHERE table_schema = 'geodaten' AND table_name = 'projekte'
            ORDER BY ordinal_position;
        `);
        res.rows.forEach(r => console.log(`${r.column_name}: ${r.data_type} (${r.is_nullable})`));
        
        console.log("\nSample data:");
        const data = await client.query("SELECT id, name FROM geodaten.projekte LIMIT 5");
        data.rows.forEach(r => console.log(`${r.id}: ${r.name}`));
    } catch (e) {
        console.error("Error:", e);
    } finally {
        await client.end();
    }
}
inspect();
