How to use NodeJS to create connection from EC2 to remote RDS (PostgreSQL) and query it?
I have this code but currently does not work (how exactly connection string should look like including password?):
var pg = require('pg');
var conString = "postgres://username:@db.us-east-2.rds.amazonaws.com:5432/testdb";
var client = new pg.Client(conString);
client.connect();
var query = client.query("SELECT * FROM t1");
//fired after last row is emitted
query.on('row', function(row) {
console.log(row);
});
query.on('end', function() {
client.end();
});