无法使用RPostgreSQL连接到AWS Redshift [英] Can't connect to AWS Redshift using RPostgreSQL

查看:235
本文介绍了无法使用RPostgreSQL连接到AWS Redshift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用RPostgreSQL连接到我的AWS Redshift数据库.

I'm not able to connect to my AWS Redshift database using RPostgreSQL.

有人能使用示例代码吗?

Does anyone have an example of code that would work?

library (RPostgreSQL)
drv <- dbDriver("PostgreSQL")
conn <- dbConnect(drv, "database.us-east-1.redshift.amazonaws.com",  "jeffz", "PsWrd123")    
Error in postgresqlNewConnection(drv, ...) : 
  RS-DBI driver: (could not connect database.us-east-1.redshift.amazonaws.com@PsWrd123 on dbname "database.us-east-1.redshift.amazonaws.com"

Windows 7 驱动程序中的postgresql-8.4-703.jdbc4 在环境中设置了jre7的路径

Windows 7 postgresql-8.4-703.jdbc4 in drivers path to jre7 is set in environment

推荐答案

我遇到了同样的问题-这是对我来说有效"的代码示例:

I had the same issue - here is an example of code that 'works' for me:

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)


完整代码在这里:


Full code here:

https://dreamtolearn.com/ryan/data_analytics_viz/93

https://github.com/rustyoldrake/AWS_Redshift_S3_R_Interface

*正如其他人所指出的那样-如果系统无法连接-确保AWS的安全性/访问权限已打开,最多可通过您的IP打开允许端口5439访问(或所有IP)-默认情况下,它们不会打开,因此,如果您不打开它们,将无法连接

* As the other person noted - if system is UNABLE TO CONNECT - ensure AWS has the security/access permissions opened up to allow Port 5439 access from YOUR IP (or all IPs) - by default they are NOT open, so if you don't open them, you will not connect

这篇关于无法使用RPostgreSQL连接到AWS Redshift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆