Reopens a snapshot that already exists in a DuckDB file. This is the durable
research workflow counterpart to ledgr_snapshot_from_df(): create and seal a
snapshot once, then load it by path and snapshot id in later R sessions.
Details
ledgr_snapshot_load() never creates or overwrites snapshots. It only returns
a handle to an existing sealed snapshot. Closing the returned object releases
its DuckDB connection; it does not delete the database file.
Articles
Durable experiment stores:
vignette("experiment-store", package = "ledgr")
system.file("doc", "experiment-store.html", package = "ledgr")
Examples
db_path <- tempfile(fileext = ".duckdb")
bars <- data.frame(
ts_utc = as.POSIXct("2020-01-01", tz = "UTC") + 86400 * 0:2,
instrument_id = "AAA",
open = c(100, 101, 102),
high = c(101, 102, 103),
low = c(99, 100, 101),
close = c(100, 101, 102),
volume = 1000
)
snapshot <- ledgr_snapshot_from_df(bars, db_path = db_path)
snapshot_id <- snapshot$snapshot_id
ledgr_snapshot_close(snapshot)
snapshot <- ledgr_snapshot_load(db_path, snapshot_id, verify = TRUE)
ledgr_snapshot_info(snapshot)
#> # A tibble: 1 × 11
#> snapshot_id status created_at_utc sealed_at_utc snapshot_hash bar_count
#> <chr> <chr> <chr> <chr> <chr> <int>
#> 1 snapshot_20260515… SEALED 2026-05-15T16… 2026-05-15T1… 4d7d3b7dda80… 3
#> # ℹ 5 more variables: instrument_count <int>, start_date <chr>, end_date <chr>,
#> # meta_json <chr>, error_msg <chr>
ledgr_snapshot_close(snapshot)