Skip to contents

Small helper function to connect to database. This way, the connection arguments are in one place, which makes it easier to change the database driver in the entire app if needed.

Usage

get_db_connection(
  path = db_path,
  drv = RSQLite::SQLite(),
  envir = parent.frame()
)

Arguments

path

Character vector. Path to the database.

drv

Database driver to use. Defaults to RSQLite::SQLite().

envir

Environment to make the connection available in.

Value

A database connection.

Examples

get_db_connection(tempfile(fileext = ".sqlite"))
#> <SQLiteConnection>
#>   DISCONNECTED