const { Client } = require('pg'); async function test_insert() { const client = new Client({ host: '87.106.21.21', port: 5432, user: 'enwelo_admin', password: 'WX1t1cgP1qK09', database: 'enwelo' }); try { await client.connect(); console.log("Connected to DB."); const projekt_id = "BWSamern-Ohne-Test"; const lat = 52.3; const lng = 7.1; await client.query('BEGIN'); await client.query('DELETE FROM geodaten.wea_standorte WHERE projekt_id = $1', [projekt_id]); console.log("Inserting test row..."); await client.query( `INSERT INTO geodaten.wea_standorte ( wea_nummer, anlagentyp, nabenhoehe, rotordurchmesser, projekt_id, geom ) VALUES ($1, $2, $3, $4, $5, ST_Transform(ST_SetSRID(ST_MakePoint($6, $7), 4326), 25832))`, ['TEST-1', 'Vestas V162', 169, 162, projekt_id, lng, lat] ); await client.query('COMMIT'); console.log("Insert successful!"); const res = await client.query('SELECT *, ST_AsText(ST_Transform(geom, 4326)) as geom_wgs84 FROM geodaten.wea_standorte WHERE projekt_id = $1', [projekt_id]); console.log("Verified entry:", JSON.stringify(res.rows, null, 2)); } catch (e) { console.error("Test failed:", e); } finally { await client.end(); } } test_insert();