bwsamern-ohne_standortplaner/backend/test_insert_status.js

32 lines
957 B
JavaScript

const { Client } = require('pg');
async function testInsert() {
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();
await client.query('BEGIN');
const res = await client.query(
`INSERT INTO geodaten.flaecheneigentuemer_status (id, fsk, projekt_id, status, datum)
VALUES (gen_random_uuid(), '034212009000090003__', '5bb4e049-85f2-4433-b38e-6a66b81e9f06', 'Gesichert', NOW()) RETURNING *`
);
console.log("Insert success:", res.rows[0]);
await client.query('ROLLBACK');
console.log("Rollback success");
} catch (e) {
console.error("Insert failed:", e);
} finally {
await client.end();
}
}
testInsert();