R Oracle connect via DBI::dbDriver("Oracle") throws error
Asked Answered
D

2

7

I try to do a simple connect to an Oracle database via DBI and ROracle package following instructions from R to Oracle Database Connectivity: Use ROracle for both Performance and Scalability.

When I test the connection via Windows7 > ODBC Data Source Administrator (32bit), the connection is successful. It uses the installed Oracle client OraClient11g_home1 which resides in C:\oracle\Client112_32. ORACLE_HOME environment variable is set to C:\oracle\Client112_32.

I am guessing it may be connected to some 32bit/64bit issue? But even after quite some research I did not find any solution. I also tried running the same in R 32bit but fails as well. BTW, the connection via SQL Developer is also successful.

drv <- DBI::dbDriver("Oracle")
#>Error: Couldn't find driver Oracle. Looked in:
#>* global namespace
#>* in package called Oracle
#>* in package called ROracle
Disloyal answered 5/1, 2018 at 13:17 Comment(0)
K
4

I've had this issue as well. I found that loading the ROracle library beforehand fixes the problem.

library("ROracle")
drv <- DBI::dbDriver("Oracle")

I don't know why though.

Karol answered 19/3, 2019 at 15:47 Comment(0)
S
3

Building on user11227405 answer: it is actually enough to load ROracle without attaching it on the search path; library() does both instead:

loadNamespace("ROracle")
drv <- DBI::dbDriver("Oracle")

that might be preferred e.g. in packages, where changing the search path should be avoided

Stationmaster answered 24/5, 2020 at 16:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.