I'm trying to connect my html/css/js web app on my localhost to a separate redshift database. I don't have access to the key/secret, so the SDK for PHP won't work for me.
Are there alternative options? I feel like I'm on the wrong track. I'm trying to query the redshift database and build some html/css graphics on my localhost.
Attempted code, per Ketan
$dbconn = pg_connect("host=endpoint dbname=name user=UN password=PW")
or die('Could not connect: ' . pg_last_error());
And error...
Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection timed out (0x0000274C/10060) Is the server running on host "endpoint" and accepting TCP/IP connections on port ####? in results.php on line 38
You don't need any key/secret to query the Redshift cluster.
Think of it as a usual PostgreSQL-based database. All you need are the following:
You could use redshift-sql in AWS lambda. Then you could invoke the lambda from web app.
var config = {
host: 'rs-cluster.us-east-1.redshift.amazonaws.com',
db: 'dev',
user: 'rsadmin',
password: 'rsPassword'
};
var rssql = require('redshift-sql')(config);
var query = 'select * from myTable limit 10';
rssql(query, function cb(err, result) {
if (err) {
return console.error(err);
}
// do stuff
});
User contributions licensed under CC BY-SA 3.0