acadflow / database /test-pg-connection.js
Vijayadhith7's picture
Upload 16 files
3d777f1 verified
raw
history blame contribute delete
666 Bytes
const { Pool } = require('pg');
require('dotenv').config();
const connectionString = process.env.SUPABASE_DB_URL;
async function test() {
console.log('Testing PG connection string:', connectionString);
const pool = new Pool({
connectionString,
ssl: { rejectUnauthorized: false }
});
try {
const client = await pool.connect();
console.log('✅ PostgreSQL connection successful!');
const res = await client.query('SELECT NOW()');
console.log('Current time from DB:', res.rows[0]);
client.release();
} catch (err) {
console.error('❌ PostgreSQL connection failed:', err.message);
} finally {
pool.end();
}
}
test();