Skip to content

Instantly share code, notes, and snippets.

@brianc
Forked from xrd/gist:784242
Created January 18, 2011 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianc/784517 to your computer and use it in GitHub Desktop.
Save brianc/784517 to your computer and use it in GitHub Desktop.
var pg = require('pg');
var cs = "postgres://blarg:blarg@localhost/blarg-upload-development";
pg.connect( cs, function( err, client ) {
//check for a connection error
if(err) {
console.log(err);
return;
}
var filename = "foobar";
var directoryId = 12345;
var query = client.query("INSERT INTO uploads(filename, directory_id) VALUES($1, $2)", [filename, directoryId]);
query.on('error', console.log); //this will log the error to the console
query.on('end', function() {
console.log("The query finished");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment