Skip to contents

DatabaseConnector cannot ATTACH on connect, and HADES opens several connections per run. This returns a function with the same arguments as connect that opens the connection and then runs each statement of readonly_attach_sql() on it. cohorts/run_plp_readonly_example.R patches DatabaseConnector::connect with it for one R session.

Usage

readonly_connect_wrapper(
  connect,
  attach_sql,
  execute = function(conn, sql) DBI::dbExecute(conn, sql)
)

Arguments

connect

The connect function to wrap, for example DatabaseConnector::connect.

attach_sql

Statements from readonly_attach_sql().

execute

Function (connection, sql) that runs one statement; defaults to DBI::dbExecute. Pass function(conn, sql) DatabaseConnector::executeSql(conn, sql, progressBar = FALSE, reportOverallTime = FALSE) for DatabaseConnector connections.

Value

A function that returns the connection after attaching.