Connecting RStudio to DashDB in the IBM Watson Studio

223 views Asked by At

How do I connect R Studio to DashDb inside IBM Watson Studio?

3

There are 3 answers

0
Sumit Goyal On

The recommended way of connecting dashDB with RStudio is using the ibmdbR package. Here, is a link to the tutorial (as already mentioned in comments by @mustaccio) http://datascience.ibm.com/blog/dashdb-r-dsx/

0
Torsten Steinbach On
0
Shad Griffin On

Thanks Guys. I really appreciate the responses. Looks like you can do it via an ODBC connection as well. This worked well for me because I speak SQL better than R.

Just make sure that the field names are all capitalized in the database. I ran into issues because the sql query has to be surrounded by quotes and non-capitalized field names in DashDB sql also require quotes. The over abundance of quotes caused the sqlQuery(myconn, ("query")) to blow up. There may be another way to deal with it, but capitalizing the fields in the database worked for me.

library(RODBC)

 dsn_driver <- "BLUDB" 
 dsn_database <- "BLUDB"  
 dsn_hostname <- "hostname"  
 dsn_port <- "50000"  
dsn_protocol <- "TCPIP"  
dsn_uid <- "userid"  
dsn_pwd <- "pw"

 conn_path <- paste(dsn_driver,  
               ";DATABASE=",dsn_database,
               ";HOSTNAME=",dsn_hostname,
               ";PORT=",dsn_port,



               ";PROTOCOL=",dsn_protocol,
               ";UID=",dsn_uid,
               ";PWD=",dsn_pwd,sep="")



 myconn <-odbcConnect(conn_path)

 df_out <- sqlQuery(myconn, ("type your sql query between the quotes"))