Skip to contents

Reads a local file and writes it to the cache so that CI and Docker environments (which may lack the original files) can still run tests.

Usage

morie_cache_file(path, table_name, db_path = NULL, con = NULL)

Arguments

path

Path to a CSV or RDS file.

table_name

Name for the cached table.

db_path

Optional path to a SQLite file (default backend).

con

Optional pre-opened DBI connection (overrides db_path).

Value

Number of rows cached (invisible).

Examples

# The SQLite backend needs the optional 'RSQLite' package.
if (requireNamespace("RSQLite", quietly = TRUE)) {
  tdir <- tempfile("morie-cache-")
  dir.create(tdir)
  f <- file.path(tdir, "demo.csv")
  write.csv(data.frame(x = 1:3, y = 4:6), f, row.names = FALSE)
  morie_cache_file(f, "demo", db_path = file.path(tdir, "cache.db"))
}