Hi, everyone,
I have the following problem:
I am using Rserver to connect to a "SQL Anyhwere 17 Database".
This is my sessionInfo:
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
*** [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ***
*** [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ***
*** [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ***
***[10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ***
attached base packages:
***[1] stats graphics grDevices utils datasets methods base ***
other attached packages:
[1] RODBC_1.3-16
loaded via a namespace (and not attached):
[1] compiler_3.6.3
The thing is that I can connect to the database when I try from the R terminal straightaway yet I cannot achieve that connection via RStudio.
When I run the following chunk I got an error that I do not get when the same commands are executed from the R terminal.
library(RODBC)
db <- "some_dsn"
channel <- RODBC::odbcConnect(db, uid = 'some_user', pwd = 'some_password')
query <- sqlQuery(channel, "SELECT * FROM table_1",
rows_at_time = 1,
believeNRows = FALSE)
close(channel)
The error I get is:
Error in sqlQuery(channel, "SELECT * FROM table_1 ", : first argument is not an open RODBC channel
I am stuck there and I cannot figure out what to do.
Any help would be highly appreciated.
Thanks a lot!!!