1

I'm having trouble connecting my R client to redshift through the RPostgreSQL package, despite it working very easily through psql. I've tried downloading and sourcing the redshift-ssl-ca-cert.pem file, but this still doesn't seem to work. Any ideas what could be causing this? Here's my R code:

library("RPostgreSQL")

drv <- dbDriver("PostgreSQL")    
host = 'host.com'
dbname = 'dbname'
port = 1234
password = 'password'
username = 'user'
redshift_cert = paste0(FILE_PATH, 'redshift-ssl-ca-cert.pem')
pg_dsn = paste0(
  'dbname=', dbname, ' ',
  'sslrootcert=', redshift_cert, ' ',
  'sslmode=verify-full'
)

con <- dbConnect(drv, dbname=pg_dsn, host=host, port=port, password=password, user=username)

and I always get this error message

Error in postgresqlNewConnection(drv, ...) : 
  RS-DBI driver: (could not connect user@host.com on dbname "dbname"
)

Meanwhile this command using psql works perfectly

psql 'host=host.com dbname=dbname sslmode=require port=1234 user=user password=password'

I've also tried other variations of sslmode including require and allow for the R code, but nothing works. Would appreciate any ideas thanks!

jtanman
  • 654
  • 1
  • 4
  • 18
  • Try keeping dbname as one literal and not the concatenation: `dbname=dbname`. Also as aside, try not having named objects the same as argument names. – Parfait Aug 25 '16 at 00:56
  • Thanks for responding! So I started with just dbname=dbname which didn't work, and then found this solution on stack overflow so tried it, and it still didn't work. Appreciate the response though, and if you have any other ideas would be glad to hear them. – jtanman Aug 25 '16 at 21:12

0 Answers0