문제

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