Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to Redshift via SSL using R

I'm currently trying to connect to a redshift database in R. This needs to be done over an SSL connection but I can't seem to find options to specify the path of the certificate file to use in dbConnect. Google hasn't been to helpful either surprisingly enough.

Is it really that difficult establish a postgres SSL connection to redshift via R or am I just missing out on something fundamental?

like image 514
Michael Aquilina Avatar asked Feb 12 '15 16:02

Michael Aquilina


People also ask

How do I connect to Redshift in R?

Connecting R to Amazon Redshift with RJDBC In R, you can install the RJDBC package to load the JDBC driver and send SQL queries to Amazon Redshift. This requires a matching JDBC driver. Choose the latest JDBC driver provided by AWS (Configure a JDBC Connection).

How do I connect to Redshift from terminal?

To connect by using psql defaults Sign in to the AWS Management Console and open the Amazon Redshift console at https://console.aws.amazon.com/redshift/ . Where: <endpoint> is the Endpoint you recorded in the previous step. <userid> is a user ID with permissions to connect to the cluster.

Can I use Toad to connect to Redshift?

In this section we shall add a new connection in Toad Data Point for a Redshift cluster. Click on Connect>New Connection as shown in Figure 1. In the list of data sources displayed select Amazon Redshift, as shown in Figure 2. In the Create New Connection window, shown in Figure 3, configure the connection parameters.


1 Answers

simply do:

host = 'redshift-name.xxxxxxxxxxxx.eu-west-1.redshift.amazonaws.com'
dbname = 'your_db_name'
port = 3306
password = 'hunter2'
username = 'rs_user'
redshift_cert = paste0(FILE_PATH, 'redshift-ssl-ca-cert.pem')
pg_dsn = paste0(
    'dbname=', dbname, ' ',
    'sslrootcert=', redshift_cert, ' ',
    'sslmode=verify-full'
)
dbConnect(RPostgreSQL::PostgreSQL(), dbname=pg_dsn, host=host, port=port, password=password, user=username)
like image 161
Thomas Grainger Avatar answered Oct 30 '22 10:10

Thomas Grainger