Shad Griffin
Shad Griffin

Reputation: 11

Connecting RStudio to DashDB in the IBM Watson Studio

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

Upvotes: 0

Views: 210

Answers (3)

Shad Griffin
Shad Griffin

Reputation: 11

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"))

Upvotes: 0

Torsten Steinbach
Torsten Steinbach

Reputation: 391

Some more samples are linked from here: http://datascience.ibm.com/blog/working-with-dashdb-in-data-science-experience/

Upvotes: 1

Sumit Goyal
Sumit Goyal

Reputation: 575

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/

Upvotes: 1

Related Questions