Store

Getting a store

Create a new instance of the class.

from ocdsmetricsanalysis.library import Store
store = Store("temp-database.sqlite")

See below for the parameters to pass.

Class reference

class ocdsmetricsanalysis.library.Store(database_filename: str)

Every time you want to work with a set of data, you need to create a store. A store has methods for adding and querying metrics and observations.

Stores do not persist data automatically; if you want to keep the data there are methods to export it as JSON that should be used before discarding the store.

Construct: Pass database_filename. This should be a file that does not already exist. It is not needed after the store is finished with and can be deleted.

add_metric(id: str, title: str, description: str)

Adds a metric to the store.

add_metric_json(data: dict)

Adds a JSON object which is a Metric class to the store. Adds the metric and any observations it contains in the JSON.

get_metric(metric_id)

Returns a specific Metric. Returns a Metric class.

get_metrics()

Returns a list of all metrics in this store. Each item in the list is a Metric class.