import pg from 'pg';
import fs from 'fs';
import dotenv from 'dotenv';

dotenv.config({path: ".env"});

const { Pool } = pg;

console.log("Connecting to PostgreSQL database");

const pool = new Pool({
    user: process.env.DBUSER,
    host: process.env.DBHOST,
    database: process.env.DBNAME,
    password: process.env.DBPASS,
    port: process.env.DBPORT
});

pool.query(fs.readFileSync('./db_schema.psql').toString());


export default pool;