safeSQLiteConnect: open a 'safe' connection to an sqlite database

Description Usage Arguments Details Value Note Author(s)

Description

In this package, all connections to sqlite database files are created by this function.

Usage

1
2
safeSQLiteConnect(path, create = FALSE, busyTimeout = 300,
  cacheSize = 200)

Arguments

path

path to database

create

should database be created if it doesn't already exist; default: FALSE

busyTimeout

value for busy_timout handler, in seconds; default: 300. A positive value causes the function to wait for another process to unlock the database, rather than returning immediately with an error.

cacheSize

size of sqlite page cache to use, in MBytes. default: 200

Details

This avoids the locking issue with the typical use of dbConnect(RSQLite::SQLite(), ...), which connects and immediately tries to set synchronous mode, unless synchronous=NULL is specified. If the database is locked, the connection fails before pragma busy_timeout can be used to set a timeout handler.

Value

a DBI:dbConnection to the sqlite database, or NULL on failure

Note

parameters, return value, and semantics are identical to dplyr::src_sqlite except that a locked sqlite database will be handled gracefully with retries.

Author(s)

minor changes from dplyr::src_sqlite by John Brzustowski


jbrzusto/motus-R-package documentation built on May 18, 2019, 7:03 p.m.