Skip to content

Instantly share code, notes, and snippets.

@xrd
Created January 18, 2011 10:00

Revisions

  1. xrd revised this gist Jan 18, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ar pg = require('pg');
    var pg = require('pg');
    var sys = require( 'sys' );
    var cs = "postgres://blarg:blarg@localhost/blarg-upload-development";

  2. xrd created this gist Jan 18, 2011.
    18 changes: 18 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    ar pg = require('pg');
    var sys = require( 'sys' );
    var cs = "postgres://blarg:blarg@localhost/blarg-upload-development";

    try {
    pg.connect( cs, function( err, client ) {
    var filename = "foobar";
    var directoryId = 12345;
    try {
    client.query("INSERT INTO uploads(filename, directory_id) VALUES($1, $2)", [filename, directoryId]);
    }
    catch( e ) {
    sys.puts( "Error: " + e.inspect );
    } } );
    }
    catch( err2 ) {
    sys.puts( "Error!: " + err2.inspect );
    }