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

import config from './config.js';

const { Pool } = pg;

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

const pool = new Pool({
    user: config.dbuser,
    host: config.dbhost,
    database: config.dbnape,
    password: config.dbpass,
    port: config.dbport
});

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


export default pool;