ROracle in RStudio Server Ubuntu 18.04

Install Oracle Insta Client

https://download.oracle.com/otn_software/linux/instantclient/19800/instantclient-basic-linux.x64-19.8.0.0.0dbru.zip

https://download.oracle.com/otn_software/linux/instantclient/19800/instantclient-sdk-linux.x64-19.8.0.0.0dbru.zip

Create directory

mkdir /opt/oracle

Unzip the contents of both files

Install AIO

sudo apt install libaio1

Execu script

sudo sh -c "echo /opt/oracle/instantclient_19_3 > \
      /etc/ld.so.conf.d/oracle-instantclient.conf"
  sudo ldconfig

Build ROracle

Sys.setenv(
  'ORACLE_HOME' = '/opt/oracle/instantclient_19_8',
  'OCI_LIB64'   = '/opt/oracle/instantclient_19_8'
)
install.packages("ROracle", type="source")

library("ROracle")

Test your script

library(ROracle)
drv <- dbDriver("Oracle")
host <- "localhost"
port <- 1521
service <- "ids"
drv <- dbDriver("Oracle")

connect.string <- paste(
  
  "(DESCRIPTION=",
  
  "(ADDRESS=(PROTOCOL=tcp)(HOST=", host, ")(PORT=", port, "))",
  
  "(CONNECT_DATA=(SERVICE_NAME=", service, ")))", sep = "")

con <- dbConnect(drv, username = "user", password = "pass", dbname = connect.string)

table_results <- dbGetQuery(con,"select * from table")
 

Leave a Reply

Your email address will not be published. Required fields are marked *