Skip to content

Commit

Permalink
simplify retrieving JDBC driver for InterSystems IRIS
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeboe committed Oct 9, 2024
1 parent 46c896b commit cc2f38d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
7 changes: 1 addition & 6 deletions R/DatabaseConnector.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ NULL
#' functions to point to the driver. Alternatively, you can set the 'DATABASECONNECTOR_JAR_FOLDER' environmental
#' variable, for example in your .Renviron file (recommended).
#'
#' # SQL Server, Oracle, PostgreSQL, PDW, Snowflake, Spark, RedShift, Azure Synapse, BigQuery
#' # SQL Server, Oracle, PostgreSQL, PDW, Snowflake, Spark, RedShift, Azure Synapse, BigQuery, InterSystems IRIS
#'
#' Use the [downloadJdbcDrivers()] function to download these drivers from the OHDSI GitHub pages.
#'
Expand All @@ -75,11 +75,6 @@ NULL
#'
#' For SQLite we actually don't use a JDBC driver. Instead, we use the RSQLite package, which can be installed
#' using `install.packages("RSQLite")`.
#'
#' # InterSystems IRIS
#'
#' For InterSystems IRIS, download the driver [here](https://intersystems-community.github.io/iris-driver-distribution/),
#' or locate the intersystems-jdbc-<version>.jar in the ./dev/java/lib/1.8/ folder of your IRIS installation.
#'
NULL

Expand Down
30 changes: 19 additions & 11 deletions R/Drivers.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jdbcDrivers <- new.env()
#' - "spark" for Spark
#' - "snowflake" for Snowflake
#' - "bigquery" for Google BigQuery
#' - "iris" for InterSystems IRIS
#' - "all" for all aforementioned platforms
#'
#' @param method The method used for downloading files. See `?download.file` for details and options.
Expand All @@ -48,6 +49,7 @@ jdbcDrivers <- new.env()
#' - Spark: V2.6.21
#' - Snowflake: V3.13.22
#' - BigQuery: v1.3.2.1003
#' - InterSystems IRIS: v3.9.0
#'
#' @return Invisibly returns the destination if the download was successful.
#' @export
Expand Down Expand Up @@ -82,7 +84,7 @@ downloadJdbcDrivers <- function(dbms, pathToDriver = Sys.getenv("DATABASECONNECT
dir.create(pathToDriver, recursive = TRUE)
}

stopifnot(is.character(dbms), length(dbms) == 1, dbms %in% c("all", "postgresql", "redshift", "sql server", "oracle", "pdw", "snowflake", "spark", "bigquery"))
stopifnot(is.character(dbms), length(dbms) == 1, dbms %in% c("all", "postgresql", "redshift", "sql server", "oracle", "pdw", "snowflake", "spark", "bigquery", "iris"))

if (dbms == "pdw" || dbms == "synapse") {
dbms <- "sql server"
Expand All @@ -96,7 +98,8 @@ downloadJdbcDrivers <- function(dbms, pathToDriver = Sys.getenv("DATABASECONNECT
4,oracle,oracleV19.8.zip,https://ohdsi.github.io/DatabaseConnectorJars/
5,spark,DatabricksJDBC42-2.6.32.1054.zip,https://databricks-bi-artifacts.s3.us-east-2.amazonaws.com/simbaspark-drivers/jdbc/2.6.32/
6,snowflake,SnowflakeV3.13.22.zip,https://ohdsi.github.io/DatabaseConnectorJars/
7,bigquery,SimbaBigQueryJDBC42-1.3.2.1003.zip,https://storage.googleapis.com/simba-bq-release/jdbc/"
7,bigquery,SimbaBigQueryJDBC42-1.3.2.1003.zip,https://storage.googleapis.com/simba-bq-release/jdbc/
8,iris,intersystems-jdbc-3.9.0.jar,https://github.com/intersystems-community/iris-driver-distribution/raw/refs/heads/main/JDBC/JDK18/"
)
if (dbms == "all") {
dbms <- jdbcDriverSources$dbms
Expand All @@ -119,16 +122,21 @@ downloadJdbcDrivers <- function(dbms, pathToDriver = Sys.getenv("DATABASECONNECT
method = method
)

extractedFilename <- unzip(file.path(pathToDriver, driverSource$fileName), exdir = pathToDriver)
unzipSuccess <- is.character(extractedFilename)

if (unzipSuccess) {
file.remove(file.path(pathToDriver, driverSource$fileName))
}
if (unzipSuccess && result == 0) {
inform(paste0("DatabaseConnector ", db, " JDBC driver downloaded to '", pathToDriver, "'."))
extension <- tail(strsplit(file.path(pathToDriver, driverSource$fileName), split=".", fixed = TRUE)[[1]],1)
if (extension == "zip") {
extractedFilename <- unzip(file.path(pathToDriver, driverSource$fileName), exdir = pathToDriver)
unzipSuccess <- is.character(extractedFilename)

if (unzipSuccess) {
file.remove(file.path(pathToDriver, driverSource$fileName))
}
if (unzipSuccess && result == 0) {
inform(paste0("DatabaseConnector ", db, " JDBC driver downloaded to '", pathToDriver, "'."))
} else {
abort(paste0("Downloading and unzipping of ", db, " JDBC driver to '", pathToDriver, "' has failed."))
}
} else {
abort(paste0("Downloading and unzipping of ", db, " JDBC driver to '", pathToDriver, "' has failed."))
inform(paste0("DatabaseConnector ", db, " JDBC driver downloaded to '", pathToDriver, "'."))
}
}

Expand Down
2 changes: 2 additions & 0 deletions man/downloadJdbcDrivers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions man/jdbcDrivers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cc2f38d

Please sign in to comment.