Created
February 15, 2017 21:36
-
-
Save kharandziuk/53b26452b38b78c39c751dac20355cd5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pg = require('pg'); | |
var client = new pg.Client(); | |
// connect to our database | |
client.connect(function (err) { | |
if (err) throw err; | |
// execute a query on our database | |
client.query('SELECT COUNT(*) FROM Hotels;', function (err, result) { | |
if (err) throw err; | |
console.log(result.rows[0]); | |
client.end(function (err) { | |
if (err) throw err; | |
}); | |
}); | |
}); | |
// call it like this: PGUSER=booking PGPASSWORD=booking PGHOST=localhost PGPORT=15432 PGDATABASE=booking node connect.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment