Skip to content

Instantly share code, notes, and snippets.

@oymgc
Created December 25, 2011 05:08
Show Gist options
  • Save oymgc/1518751 to your computer and use it in GitHub Desktop.
Save oymgc/1518751 to your computer and use it in GitHub Desktop.
node+postgres sample
var pg = require('pg');
var dbuser ="userid:password";
var dbsrv = "localhost:5432";
var db = "postgres";
var conString = "pg://" + dbuser + "@" + dbsrv + "/" + db ;
pg.connect(conString, function(err, client) {
client.query("SELECT NOW() as when" ,function(err,result) {
console.log("Row count: %d", result.rows.length);
console.log("Current year %d", result.rows[0].when.getYear());
});
});
pg.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment