Connect Redshift PostgreSQL through Node and Meteor

1.3k Views Asked by At

I have tried pg and other modules and packages to connect Redshift PostgreSQL through Node and Meteor.

This is my recent code written in node. It is unable to connect to Redshift. The client.connect function never responds.

But if I try to connect to some other PostgreSQL server, like localhost or some other remote server, then the code works as expected.

Same is the problem with Meteor.

var pg = require('pg');

var conString = "postgres://User:Password@EndPoint/Database";
//var conString = "postgres://postgres:postgres@localhost/postgres";

console.log("Started...");

var client = new pg.Client(conString);

console.log("Client", client);

client.connect(function(err) {
  if(err) {
    return console.error('could not connect to postgres', err);
  }
  client.query('SELECT NOW() AS "theTime"', function(err, result) {
    if(err) {
      return console.error('error running query', err);
    }
    console.log(result.rows[0].theTime);
    //output: Tue Jan 15 2013 19:12:47 GMT-600 (CST) 
    client.end();
  });
});

console.log("End...");

I want to connect through Meteor. But if not possible through Meteor, Node.js will also work.

0

There are 0 best solutions below