45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { Pool } from "pg";
|
|
|
|
const pool = new Pool({
|
|
connectionString:
|
|
"postgres://openswe:openswe_password_123@localhost:5432/cyberhybridhub_realestate",
|
|
});
|
|
|
|
try {
|
|
console.log("Attempting to connect to PostgreSQL...");
|
|
const client = await pool.connect();
|
|
console.log("✅ Connected to PostgreSQL!");
|
|
|
|
const result = await client.query("SELECT version()");
|
|
console.log("PostgreSQL version:", result.rows[0]);
|
|
|
|
const tables = await client.query(`
|
|
SELECT table_name, table_schema
|
|
FROM information_schema.tables
|
|
WHERE table_schema = 'memory'
|
|
OR table_schema = 'checkpoints'
|
|
OR table_schema = 'public'
|
|
ORDER BY table_schema, table_name
|
|
`);
|
|
console.log("Tables found:", tables.rows.length);
|
|
console.log(
|
|
"Tables:",
|
|
tables.rows.map((r: { table_schema: string; table_name: string }) =>
|
|
`${r.table_schema}.${r.table_name}`
|
|
),
|
|
);
|
|
|
|
client.release();
|
|
await pool.end();
|
|
} catch (error: unknown) {
|
|
console.error(
|
|
"❌ Database connection failed:",
|
|
error instanceof Error ? error.message : String(error),
|
|
);
|
|
if (error instanceof Error && error.cause) {
|
|
console.error("Cause:", error.cause);
|
|
}
|
|
await pool.end();
|
|
Deno.exit(1);
|
|
}
|