Skip to content
potluckdb

Snapshot

Node: also in Python · Go · Rust · Swift · Dart · Java and Kotlin · .NET · C++ · Objective-C

One exact retained read-only revision.

A snapshot has no mutation, transaction, connection, checkpoint, synchronization or conflict API. Reads fetch and authenticate pages on demand, as on a writable database. Concepts explains revisions and retention.

Close the snapshot. Repeated calls have the same effect.

This never closes your Remote.

Run one statement with read execution intent against the pinned revision. Bounded by the snapshot connection’s maximumRows.

Return a typed SnapshotStatus of snapshot-owned state only.

Queries return columns, the select list’s names in order, and rows, plain objects keyed by column name. A duplicate name keeps its last position’s value.

Every SQL integer arrives as a number, including rowsAffected and lastInsertId. SQLite integers are 64-bit. Numbers represent integers exactly only within ±2^53. Reading a stored value beyond that fails with unsafe_integer instead of rounding it.

Opening with readBigInts: true returns every SQL integer as a bigint. In that mode, 1n === 1 is false, and JSON.stringify throws on bigints instead of serializing them.

SQL BLOBs arrive as Uint8Array. A bound Uint8Array, including Node’s Buffer, is a BLOB.

This is demonstrated by node/quickstart_local.js, which is executed against the published package on every release.

Use query to choose the engine. Default reads use SQLite. Select DuckDB with { engine: "duckdb" }. Only these two engines are supported. An invalid selection fails instead of selecting the default.

The native SDK loads DuckDB when you first request an analytical read. OpenOptions.analyticalEngine selects the library for one database or snapshot. It takes priority over POTLUCKDB_DUCKDB_LIBRARY, package discovery where available, and the platform’s library search. An explicit selection, including an empty string, never uses a fallback.

See analytics engine installation for your platform. Without an implicit library, the read fails with analytical_engine_unavailable. If an explicit library cannot load, the read reports its loader error.

Install with npm install @potluckdb/potluckdb-analytics. Its optional dependencies provide one package per platform. npm downloads only the engine this machine can load.

DuckDB rejects the named binding forms :name and @name. Both engines accept $name and positional ? bindings. Booleans bind as INTEGER 0/1 on both. IS therefore asks the same question on either engine, unlike a DuckDB BOOLEAN binding.

Bare table names read the database’s main schema. Qualifiers such as temp. are not seen. For table names ending in .csv, .parquet or .json, use potluckdb_scan('name'). DuckDB otherwise treats those names as files.

NUMERIC and DECIMAL columns read as doubles. A value that a double cannot hold exactly fails the query instead of arriving rounded.

A storage failure during an analytical read reports analytical_engine_error, with the failure named in its message. The same query succeeds when storage answers.

Either engine runs one read per query. The analytical engine reads a snapshot of the same data through its own in-memory database. A statement sent to this engine therefore cannot change the stored data.

An engine can remain for the session’s lifetime. Changing its settings or catalog would change later queries on that session. Only SELECT and EXPLAIN are accepted. CREATE, SET, ATTACH, PREPARE and EXPLAIN ANALYZE are refused. EXPLAIN ANALYZE is refused because it executes the explained statement.

Use execute for writes to the stored data.