Skip to content

Usage

How to use the package. Design is what it is and why; API Reference is the generated signatures.

Installation

pip install datarecord           # core
pip install datarecord[pypsa]    # with the PyPSA tool

Or with conda/mamba, from conda-forge:

conda install -c conda-forge datarecord

Connections

Every entry point takes a DuckDB connection. It is passed as a parameter throughout, never a module global, and is scoped to one record root — which is how the schema beside its layers is found without a separate argument.

from datarecord import connect

con = connect(":memory:", base_uri="s3://bucket/my-record")

connect opens a connection carrying the revisions table and the path macros, loading httpfs and S3 credentials only for a remote base_uri. base_uri defaults to the DATARECORD_BASE_URI environment variable.

The pages

page what it covers
Reading a record the Record protocol, frames, flags
The schema declaring dims and attributes
Layers revisions, branching, materialising
Editing WorkingRecord: set, add, commit
Writing write_record
Tools consuming a record from a modelling framework