Skip to contents

Creates a row in snapshots with status CREATED. Does not import any data.

Usage

ledgr_snapshot_create(con, snapshot_id = NULL, meta = NULL)

Arguments

con

A DBI connection to DuckDB.

snapshot_id

Optional snapshot identifier.

meta

Optional JSON-safe metadata list (stored as canonical JSON).

Value

The snapshot_id (character(1)).

Details

Snapshot mutability rule: snapshots are mutable only while their status is CREATED (imports/seal will fail for SEALED and FAILED snapshots).

If snapshot_id is NULL, generates an id of the form snapshot_{YYYYmmdd_HHMMSS}_{4-hex} (v0.1.1 spec, appendix A section 3.1).

Timestamps are stored in UTC and normalized to ISO8601 ...Z form.

Errors:

  • ledgr_snapshot_exists if snapshot_id already exists.

Articles

Durable experiment stores: vignette("experiment-store", package = "ledgr") system.file("doc", "experiment-store.html", package = "ledgr")

Examples

db_path <- tempfile(fileext = ".duckdb")
con <- ledgr_db_init(db_path)
snapshot_id <- ledgr_snapshot_create(
  con,
  snapshot_id = "snapshot_20200101_000000_abcd"
)
snapshot_id
#> [1] "snapshot_20200101_000000_abcd"
DBI::dbDisconnect(con, shutdown = TRUE)