본문 바로가기

Programming/Javascript

Javascript postgresql 연동

반응형
const { Client } = require('pg');

const client = new Client({
    host : 'localhost',
    database: 'postgres',
    user: 'postgres',    
    password: 'asdf4416',
    port: 5432,
});

client.connect();

client.query('SELECT * FROM member', (err, res) =>{
    if(err){
        console.log(err);
    }else{
        console.log(res);
    }
});
반응형