pythonroracle-databaseroracle

Connecting R to Oracle DB without admin


I need an R script that allows me to connect to an Oracle DB without having to install anything needing admin powers, and preferrably nothing at all apart from package downloads. In python the following code works, I believe because it uses the cx_Oracle module as a portable driver. What would be a good R alternative?

import pandas as pd
import sqlalchemy
import sys
host = "xxx.intra"
database = "mydb"
user = "usr"
password = "pw"
def get_oracle_engine(host, database, user, password):
   return sqlalchemy.create_engine("oracle+cx_oracle://{user}:{password}@{host}:1521/?service_name={database}".format(host=host, database=database, user=user, password=password))
engine=get_oracle_engine(host, database, user, password)    
pd.read_sql_table("mytable", engine, schema= mydb,index.cols="id1")

I managed to install ROracle using the CRAN instructions but I keep getting the ORA-12154 TNS: cound not resolve the connect identifier specified when using:

library(ROracle)
con= DBI::dbconnect(dbDriver("Oracle"), user= user, password=password, host=host, dbname=database, port="1521")

By the way dbDriver("Oracle") returns

Driver name : Oracle (OCI) 
Driver version: 1.3-1
Client version: 12.1.0.2.0

Solution