使用R通过SSL连接到Redshift
问题描述:
我当前正在尝试连接到R中的redshift数据库.这需要通过SSL连接完成,但是我似乎找不到用于指定要在dbConnect
中使用的证书文件路径的选项.谷歌一直没有提供足够的帮助.
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.
真的很难建立一个Postgres SSL连接以通过R进行红移,还是我只是错过了一些基本的东西?
Is it really that difficult establish a postgres SSL connection to redshift via R or am I just missing out on something fundamental?
答
只需:
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)