first commit
This commit is contained in:
21
db/test-conn.ts
Normal file
21
db/test-conn.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
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();
|
||||
Reference in New Issue
Block a user