Guest User

Untitled

a guest
Sep 22nd, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. var pgp = require('pg-promise')(/*options*/);
  2.  
  3. var cn = {
  4. host: 'localhost', // server name or IP address;
  5. port: 5432,
  6. database: 'trading_database_eur_usd',
  7. user: 'postgres',
  8. password: '7256'
  9. };
  10. // alternative:
  11. // var cn = 'postgres://username:password@host:port/database';
  12.  
  13. var db = pgp(cn); // database instance;
  14.  
  15. // select and return user name from id:
  16. db.one('SELECT * FROM eur_usd WHERE OPEN_PRICE > 1.12918;')
  17. .then(user => {
  18. console.log(user.name); // print user name;
  19. })
  20. .catch(error => {
  21. console.log(error); // print the error;
  22. });
Add Comment
Please, Sign In to add comment