Sets up an example database for codeminer with dummy data,
sets the environment variable CODEMINER_DB_PATH, and connects
the workbench. Any subsequent codeminer actions will use this database.
Usage
create_dummy_database(
db_path = tempfile(fileext = ".duckdb"),
...,
verbose = FALSE,
.local = FALSE,
.envir = parent.frame()
)Arguments
- db_path
Path to the database file. Defaults to a temporary file. This is to avoid writing the dummy data to an already existing database.
- ...
These dots are for future extensions and must be empty.
- verbose
If
TRUE, prints progress messages during the database build. Defaults toFALSEfor cleaner output.- .local
If
FALSE(default), setsCODEMINER_DB_PATHglobally viaSys.setenv(). The dummy database persists until you reconnect manually. IfTRUE, useswithr::local_envvar()scoped to.envirso the environment variable and workbench are automatically cleaned up when.envirexits. Use.local = TRUEin tests and functions that need automatic teardown.- .envir
Environment for scoped cleanup when
.local = TRUE. Ignored when.local = FALSE. Defaults to the calling environment.
Examples
# Create dummy database in a temporary location
temp_db <- tempfile(fileext = ".duckdb")
create_dummy_database(temp_db)
#> ✔ Dummy database ready to use!
#> ℹ To reconnect to your previous database:
#> `Sys.setenv(CODEMINER_DB_PATH = "/tmp/RtmpXyzdMY/file19d423f0733f.duckdb")`
#> `codeminer_connect()`
# This also sets the environment variable `CODEMINER_DB_PATH`
Sys.getenv("CODEMINER_DB_PATH")
#> [1] "/tmp/RtmpXyzdMY/file19d426bc1fe3.duckdb"