ayush biyani
ayush biyani

Reputation: 147

connecting oracle from r

I am new to R and trying to connect to Oracle using the way told here.

I downloaded instant client but could not find anything apart from some .dll files there.

Request all to please guide me step by step as to how to connect to Oracle from R. I have had a look at some of the solutions but they couldnt work out.

Please tell me if at all there, the prerequisites to connecting to oracle from R. BTW, I am using oracle sql developer.

Upvotes: 2

Views: 2552

Answers (2)

Sean
Sean

Reputation: 3955

If the client that you already use on your desktop uses JDBC, then it's probably simplest to use RJDBC package and use the same URLs that your desktop package used!

library(RJDBC)
drv <- JDBC("oracle.jdbc.OracleDriver",
            "/home/sean/local/DbVisualizer/jdbc/oracle/ojdbc6.jar", "`")
conn <- dbConnect(drv, "jdbc:oracle:thin://localhost/test")
dbListTables(conn)
data(iris)
dbWriteTable(conn, "iris", iris)
dbGetQuery(conn, "select count(*) from iris")
d <- dbReadTable(conn, "iris")

You'll obviously have to change the path to the driver jar file and the connection string.

It might not be quite as fast as a native driver, but I found it easier to get working!

Upvotes: 2

Prasun Velayudhan
Prasun Velayudhan

Reputation: 547

I advice best way is to install oracle R enterprise edition packages.

This will help to connect to oracle as well as it includes many other features. You can download these packages for free from the below link.

http://www.oracle.com/technetwork/database/options/advanced-analytics/r-enterprise/ore-downloads-1502823.html

Download Client as well as Client Supporting packages and install these packages through either R console or R Studio. Once installed use library(ore) to load the library. you can use ore.connect() function to connect to oracle and ore.sync() function to sync the tables and views into r so that u can use that as r objects. You can refer this document for the syntax for ore.connect() and also for other available functions.

http://www.oracle.com/technetwork/database/options/advanced-analytics/r-enterprise/ore-reference-manual-1882822.pdf

ore.ls() will help you to list the available ore objects. to use it as an r data frame use the function: data=ore.pull(table_name)

Upvotes: 1

Related Questions