Question

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?

Was it helpful?

Solution

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=...)

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top