22 lines
474 B
TypeScript
22 lines
474 B
TypeScript
import { Client } from 'pg';
|
|
import * as dotenv from 'dotenv';
|
|
|
|
dotenv.config({ path: '.env.local' });
|
|
|
|
async function test() {
|
|
const client = new Client({
|
|
connectionString: process.env.DATABASE_URL,
|
|
});
|
|
try {
|
|
await client.connect();
|
|
console.log("Connected successfully");
|
|
const res = await client.query('SELECT NOW()');
|
|
console.log(res.rows[0]);
|
|
await client.end();
|
|
} catch (err) {
|
|
console.error("Connection error", err);
|
|
}
|
|
}
|
|
|
|
test();
|