I've been connecting successfully to our Oracle server using ROracle/DBI for some time, and now I wonder if there is a way to show/manage/use this connection in the connections pane. Our server uses Oracle's OCI and currently does not have ODBC available. Also, this server and the RStudio Server Pro installation I'm using when I connect to it are both not connected to the internet except when our IT staff are performing system updates.
Supposing I have already set strings for host
, port
, svc
, the connection I've been using goes something like this, adapted from the ROracle docs:
library(ROracle)
connect_string <- paste0(
'(DESCRIPTION=',
'(ADDRESS=(PROTOCOL=tcps)(HOST=', host, ')(PORT=', port, '))',
'(CONNECT_DATA=(SERVICE_NAME=', svc, ')))')
drv <- dbDriver('Oracle')
con <- tryCatch(
dbConnect(drv,
username = rstudioapi::askForPassword('Enter username: '),
password = rstudioapi::askForPassword('Enter your Oracle database password: '),
dbname = connect_string),
error = function(cond) message(cond),
warning = function(cond) message(cond)
)
Where con
is of class OraConnection
and drv
is OraDriver
, implementations of DBI provided by the ROracle package. From here I can send SQL statements with dbSendQuery()
, fetch()
, etc.
Is there some way I can get this set up in the connections panel?
Bonus: Will dplyr/dbplyr support this?
Thanks!
Brian