Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect R and Teradata using JDBC

I´m trying to connect R and Teradata using RJDBC.

I´ve found this link that has an example using mysql, but i´m nos sure how to do the same with teradata.

library(RJDBC)
drv <- JDBC("com.mysql.jdbc.Driver",
           "/etc/jdbc/mysql-connector-java-3.1.14-bin.jar",
           identifier.quote="`")
conn <- dbConnect(drv, "jdbc:mysql://localhost/test", "user", "pwd")

I´ve downloaded this driver: http://downloads.teradata.com/download/connectivity/jdbc-driver But i´m not sure where i should reference the directory.

I know there is a teradataR package out there, but i don´t know if it really works with the R 3.0.0.

For the time being i´m just interesting in pulling data out of the database. Something as simple as SELECT * FROM table. The problem is RODBC is very slow...

Are there other options for doing this task?

like image 620
marbel Avatar asked Feb 14 '23 04:02

marbel


1 Answers

Using the R Console, enter the following steps below to make a Teradata connection:

drv = JDBC("com.teradata.jdbc.TeraDriver","ClasspathForTeradataJDBCDriverFiles") 

Example:

drv = JDBC("com.teradata.jdbc.TeraDriver","c:\\terajdbc\\terajdbc4.jar;c:\\terajdbc\\tdgssconfig.jar")  

NOTE: A path on a UNIX machine would use single forward slashes to separate its components and a colon between files.

conn = dbConnect(drv,"jdbc:teradata://DatabaseServerName/ParameterName=Value","User","Password") 

Example:

conn = dbConnect(drv,"jdbc:teradata://jdbc1410ek1.labs.teradata.com/TMODE=ANSI,LOGMECH=LDAP","guestldap","passLDAP01")

NOTE: Connection parameters are optional. The first ParameterName is separated from the DatabaseServerName by a forward slash character.

dbGetQuery(conn,"SQLquery")

Example:

dbGetQuery(conn,"select ldap from dbc.sessioninfov where sessionno=session")
like image 158
Prasanna Nandakumar Avatar answered Feb 26 '23 23:02

Prasanna Nandakumar