Skip to contents

SAIL Databank Logo



An unofficial package to interface and interact with SAIL Databank’s database via R.

Getting Started

Installation

  1. Installing saildb whilst inside SAIL’s TRE Gateway:
    • Running the installer.R script found within R:/R_Packages/SAIL_DBI directly, or by sourcing it:
    # Somewhere in your project
    source('R:/R_Packages/SAIL_DBI/installer.R')
    # Install from resource (`R:/`) directory somewhere in your project
    install.packages(
      pkgs   = 'R:/R_Packages/SAIL_DBI/saildb_1.0.0.tar.gz',
      repos  = NULL,
      source = 'source'
    )
  2. Installing saildb whilst outside the gateway:

[!IMPORTANT]
You won’t be able to use this method whilst inside the gateway as
Github is blocked for security; use the first method if you are
developing inside the gateway

# Install devtools if not already installed
install.packages('devtools')

# Install from github
devtools::install_github('JackScanlon/SAILDB-R')

Connecting to SAIL’s DB

Once installed, you may connect to the database as described below:

# Load the package
library(saildb)

# Connect to the datase
#
#  NOTE:
#   - You will be automatically connected using your gateway credentials if
#     they have already been stored by `saildb::Profile`; otherwise you will
#     be prompted to enter your username/password
#
db = Connection$new()

# Check if we're connected (not required)
if (db$connected) {
  print('We are connected!')
}

# Perform some query
db$run("
  SELECT
      'Hello, world!' AS MESSAGE
    FROM SYSIBM.SYSDUMMY1;
")

Example usage

To view detailed examples and their explanations, see:

  • If you’re viewing from the documentation website: please see the Reference page(s) and the available article(s), e.g. the Connection article
  • If you’re viewing via Github: please see the documentation and vignettes