Connecting to Various Database Platforms

An R 'DataBase Interface' ('DBI') compatible interface to various database platforms ('PostgreSQL', 'Oracle', 'Microsoft SQL Server', 'Amazon Redshift', 'Microsoft Parallel Database Warehouse', 'IBM Netezza', 'Apache Impala', 'Google BigQuery', 'Snowflake', 'Spark', 'SQLite', and 'InterSystems IRIS'). Also includes support for fetching data as 'Andromeda' objects. Uses either 'Java Database Connectivity' ('JDBC') or other 'DBI' drivers to connect to databases.


DatabaseConnector

Build Status codecov.io CRAN_Status_Badge CRAN_Status_Badge

DatabaseConnector is part of HADES.

Introduction

This R package provides function for connecting to various DBMSs. Together with the SqlRender package, the main goal of DatabaseConnector is to provide a uniform interface across database platforms: the same code should run and produce equivalent results, regardless of the database back end.

Features

  • Create connections to the various database platforms:
    • MicrosoftSQL Server
    • Oracle
    • PostgresSql
    • Microsoft Parallel Data Warehouse (a.k.a. Analytics Platform System)
    • Amazon Redshift
    • Google BigQuery
    • SQLite
    • Spark
    • InterSystems IRIS
  • Statements for executing queries with
    • Error reporting to file
    • Progress reporting
    • Multiple statements per query
  • Support for fetching data to Andromeda objects
  • Insert data frame to a database table, using bulk loading if appropriate environmental variables are set.
  • Supports the DBI interface.
  • Supports the dbplyr interface.
  • Integrates with RStudio's Connections tab

Examples

connectionDetails <- createConnectionDetails(dbms="postgresql", 
                                             server="localhost",
                                             user="root",
                                             password="blah")
conn <- connect(connectionDetails)
querySql(conn,"SELECT COUNT(*) FROM person")
disconnect(conn)

Technology

DatabaseConnector is an R package using Java's JDBC drivers and other DBI drivers.

System Requirements

Running the package requires R with the package rJava installed. Most of the JDBC drivers will run on Java >= 8. However, some drivers (e.g. Spark / DataBricks) will require a higher Java version. We recommend running Java 21, which is the version used in our continuous integration.

Installation

  1. See the instructions here for configuring your R environment, including Java.

  2. To install the latest stable version, install from CRAN:

install.packages("DatabaseConnector")
  1. Download the database drivers as described here.

  2. (Optionally) To use Windows Authentication for SQL Server, download the authentication DDL file as described here.

User Documentation

Documentation can be found on the package website.

PDF versions of the documentation are also available:

Support

Contributing

Read here how you can contribute to this package.

License

DatabaseConnector is licensed under Apache License 2.0. The JDBC drivers fall under their own respective licenses.

Development

DatabaseConnector is being developed in R Studio.

Development status

Stable. The code is actively being used in several projects.

Acknowledgements

  • This project is supported in part through the National Science Foundation grant IIS 1251151.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("DatabaseConnector")

8.0.0 by Martijn Schuemie, 15 days ago


https://ohdsi.github.io/DatabaseConnector/, https://github.com/OHDSI/DatabaseConnector


Report a bug at https://github.com/OHDSI/DatabaseConnector/issues


Browse source code at https://github.com/cran/DatabaseConnector


Authors: Martijn Schuemie [aut, cre] , Marc Suchard [aut] , Adam Black [aut] , Observational Health Data Science and Informatics [cph] , Microsoft Inc. [cph] (SQL Server JDBC driver) , PostgreSQL Global Development Group [cph] (PostgreSQL JDBC driver) , Oracle Inc. [cph] (Oracle JDBC driver) , Amazon Inc. [cph] (RedShift JDBC driver)


Documentation:   PDF Manual  


Apache License license


Imports rJava, SqlRender, methods, stringr, readr, rlang, utils, DBI, urltools, bit64, checkmate, digest, dbplyr

Suggests aws.s3, R.utils, withr, testthat, DBItest, knitr, rmarkdown, RSQLite, ssh, Andromeda, dplyr, RPostgres, odbc, duckdb, bigrquery, pool, ParallelLogger, AzureStor, data.table

System requirements: Java (>= 8)


Imported by Characterization, CommonDataModel, OdysseusCharacterizationModule, OdysseusPathwayModule, OdysseusSurvivalModule, OhdsiReportGenerator, OhdsiShinyAppBuilder, PatientLevelPrediction.

Depended on by Achilles, CohortGenerator, CohortIncidence, CohortMethod, DataQualityDashboard, FeatureExtraction, ResultModelManager, SelfControlledCaseSeries, SelfControlledCohort.

Suggested by CDMConnector, Eunomia, OmopOnSpark, TreatmentPatterns, tidyOhdsiSolutions.


See at CRAN