I'm trying to retrieve data from greenplum cluster into R (win client). I've tried:

library("RODBC")
conn <- odbcDriverConnect("DSN_name")
Sql <- "select * from DB.st.country"
cen_data <- sqlQuery(conn,Sql)
print(cen_data)

I'm getting error: 0A000 7 ERROR: cross-database references are not implemented

I have seen some answers about dblink but when I tried: sql <- "select dblink_connect('conn', 'dbname=myDB');" cen_data <- sqlQuery(conn,Sql)

I'm getting error: "42883 7 ERROR: function dblink_connect(unknown, unknown) does not exist

Does anyone have any idea what Am I doing wrong?

有帮助吗?

解决方案

Instead of ODBC, you can also use the RPostgreSQL package, which uses DBI as the backend.

drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, host="hostname", user=..., pass=...)

其他提示

This is not an R issue (syntax is ok). The problem was in database definitions. You need to have the database in the "select data source". for that you need to have postgreSQL.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top