Returns the database path to use, by order of precedence: an R option, an
environment variable, then a default. Projects set the default in their
paths_and_packages.R; the option or the environment variable point a run
to a copy of the database (to test a change, or to read while a collection
holds the lock) without editing any script.
See also
Other connections:
db_connect(),
db_connect_read_only(),
db_disconnect(),
db_snapshot_path()
Examples
resolve_db_path("~/data/project/project.duckdb", env_var = "PROJECT_DUCKDB")
#> [1] "/home/agoutsmedt/data/project/project.duckdb"
withr::with_options(
list(project.db_path = "/tmp/copy.duckdb"),
resolve_db_path("~/data/project/project.duckdb", option = "project.db_path")
)
#> [1] "/tmp/copy.duckdb"