我有同样的问题 - 这是一个对我“有效”的代码示例:
使用库 (RPostgreSQL)
library (RPostgreSQL)
drv <- dbDriver("PostgreSQL")
con1 <- dbConnect(drv, host="hydrogen2.YOURHOST.us-east-1.redshift.amazonaws.com",
port="5439",
dbname="mydb",
user="master_user",
password=password)
con1 # check that you have a connection (e.g. <PostgreSQLConnection:(8892,0)> )
### Make sure AWS has the security/access permissions opened up to allow Port 5439 access from YOUR IP (or all IPs)
使用库(RODBC)
password <- read.table(file="private.txt", header=FALSE) # where I'm holding pw
password <- paste(password[1,1], sep="") #
library(RODBC)
con2 <- odbcConnect("AWS_hydrogen2_source", uid = "master_user", pwd = password) # east region
con2 # works! if a positive integer, you are connected
odbcGetInfo(con2)
完整代码在这里:
https://dreamtolearn.com/ryan/data_analytics_viz/93
https://github.com/rustyoldrake/AWS_Redshift_S3_R_Interface
* 正如其他人所说 - 如果系统无法连接- 确保 AWS 已打开安全/访问权限以允许从您的 IP(或所有 IP)访问端口 5439 - 默认情况下它们未打开,所以如果您不打开t打开它们,您将无法连接