How to use R node in KNIME to connect to databases

Hei there

 

In R I use something like this to read data from database:

library("RODBC");
td_reed <- odbcConnect("td_reed",uid="AAAAAA",pwd="BBBB");

Tablea <- sqlQuery(td_reed, " sel * from  prd.Table1 ")

 

I use the same code in R Workspace to read the data. The value of td_reed is returned -1 and I get an error that reads as following:

"Error: first argument is not an open RODBC channel"

Any idea how to fix it?

Thanks in advance.

MahdiP

Hi MahdiP!

This problem seems to be not restricted to KNIME, I found something similar (on linux) here: https://support.rstudio.com/hc/en-us/community/posts/211021467-Can-t-connect-to-SQL-database-using-RODBC-through-Rstudio-but-can-using-R-in-shell-

You could try right-clicking the node after running it and open the StdErr view, which may give you a more detailed error message. If that doesn't help, please tell me and I will try to reproduce your error next Tuesday.

Apart from that:
Which operating system are you on?
Which version of R and RODBC are you using?

Kind regards, Jonathan.