Skip to content

Instantly share code, notes, and snippets.

@fbenevides
Created February 18, 2011 18:19
Show Gist options
  • Save fbenevides/834134 to your computer and use it in GitHub Desktop.
Save fbenevides/834134 to your computer and use it in GitHub Desktop.
connection to pg
var http = require('http');
var config = {
user: 'postgres',
database: 'database',
port: 5432,
host: 'host',
password: 'pass'
};
var pg = require('pg');
pg.connect(config, function (err, client) {
if (err) {
console.log(err)
}
client.query('select * from colaborador', function (err, result) {
if (!err) {
console.log(result);
}
})
});
http.createServer(function (req, res) {
res.writeHead(200, {'Content-type': 'text/plain'});
res.end('Hello World');
}).listen(8082, "127.0.0.1");
console.log('Server is up and running at localhost');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment