Skip to main content

HoLcStore

HoLcStore is a Django app for creating a simple TimeSeries store in your database.

Table of Contents

Getting Started

  1. Add "holcstore" to your INSTALLED_APPS setting like this
    INSTALLED_APPS = [
        ...,
        "holcstore",
    ]
  1. Start using the abstract model Store by importing it
    from hostore.models import Store

    class YourStore(Store):
        # add new fields

        class Meta(Store.Meta):
            abstract = False
            # add your meta

Choose the appropriate store

Store class

This class is used to store timeseries, using a key:value pattern. A prm key is used to reference the saved series.

Handle update and replace features.

TimeseriesStore class

This class is used to store timeseries, using a user provided pattern through its model.

TimeseriesStore class

This class is used to store timeseries, using a user provided pattern through its model.

Handle update and replace features.

Store timeseries by chunk for a better performance with large timeseries.

User friendly API to perform a client-server sync.

Basic Usage: Store class

Saving a timeserie to database

    from path.to.YourStore import YourStore
    import pandas as pd

    key = "3000014324556"
    client_id = 0
    idx = pd.date_range('2024-01-01 00:00:00+00:00', '2024-01-02 00:00:00+00:00', freq='30min')
    ds = pd.Series(data=[1]*len(idx), index=idx)
    # Put the load curve to the store without versionning
    YourStore.set_lc(key, ds, client_id)
    # If you want to activate the versionning 
    YourStore.set_lc(key, ds, client_id, versionning=True)
    # Each time you call set_lc with your id, a new version will be saved in the database

Saving multiple timeseries to database

    from path.to.YourStore import YourStore
    import pandas as pd

    key = "3000014324556"
    client_id = 0
    idx = pd.date_range('2024-01-01 00:00:00+00:00', '2024-01-02 00:00:00+00:00', freq='30min')
    df = pd.Series(data={'key1': [1]*len(idx), 'key2': [2]*len(idx), }, index=idx)
    # Put the load curve to the store without versionning
    YourStore.set_many_lc(df, client_id)
    # If you want to activate the versionning 
    YourStore.set_many_lc(df, client_id, versionning=True)

Getting a load curve from the database

    from path.to.YourStore import YourStore

    key = "3000014324556"
    client_id = 0
    # Get the load curve from the database
    # I multiple versions exists, they will be combined beginning with the version 0 and using 
    # https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.combine_first.html
    datas = YourStore.get_lc(key, client_id)
    
    if not datas:
        my_timeserie = datas[0]['data']
        last_updated = datas[0]['last_modified']
    
    # If you want to retreive all versions 
    datas = YourStore.get_lc(key, client_id, combined_versions=False)
    # datas contains all timeseries linked to key
    
    # If you want to retreive a specific version
    datas = YourStore.get_lc(key, client_id, version=1)

Basic Usage: TimeseriesStore class

Define your class in models.py

class MyTimeseriesStore(TimeseriesStore):
    year = models.IntegerField()
    kind = models.CharField(max_length=100)

    class Meta(TimeseriesStore.Meta):
        unique_together = ('year', 'kind')

Usage samples

# specify attributes to set
ts_attrs = dict(year=2020, kind='a')

# build a timeserie 
ds_ts = pd.Series(...)  

# set timeserie to db
MyTimeseriesStore.set_ts(ts_attrs, ds_ts)

# update existing timeserie in db (will combine ds_ts + ds_ts_v2, giving priority to ds_ts_v2 datas)
MyTimeseriesStore.set_ts(ts_attrs, ds_ts_v2, update=True)

# get timeserie from db if unique match
ds_ts = MyTimeseriesStore.get_ts(ts_attrs, flat=True)

# get timeseries from db if multiple match
datas = MyTimeseriesStore.get_ts(ts_attrs)
ds_ts1 = datas[0]['data']

Basic usage : TimeseriesChunkStore class

Compact time-series storage for Django + PostgreSQL

TimeseriesChunkStore is an abstract Django model that lets you persist high-resolution time-series efficiently as compressed LZ4 blobs, while still querying them through the ORM.

Main features

Feature Description
Chunking Split each series by ('year',) or ('year','month') so blobs stay small.
Compression Data saved as LZ4-compressed NumPy buffers; index is rebuilt on the fly.
Dense layout Each chunk is re-indexed on a regular grid (STORE_FREQ, STORE_TZ).
Smart upsert set_ts(..., update=True) merges with existing data via combine_first.
Bulk helpers set_many_ts() / yield_many_ts() for mass insert / streaming read.
Sync ready list_updates, export_chunks, import_chunks enable cheap client ↔ server replication.
REST scaffolding TimeseriesChunkStoreSyncViewSet + TimeseriesChunkStoreSyncClient give you plug-and-play API endpoints and a Python client.

Quick start

1/ Define your store class

# models.py
class MyChunkedStore(TimeseriesChunkStore):
    # Custom fields (can be seen as "axis keys")
    version = models.IntegerField()
    kind    = models.CharField(max_length=20)

    # Store settings
    CHUNK_AXIS = ('year', 'month')   # Chunking axis for timeseries storage. Configs : ('year',) / ('year', 'month')
    STORE_TZ   = 'Europe/Paris' # Chunking timezone (also timeseries output tz)
    STORE_FREQ   = '1h' # Timeseries storage frequency. (the store reindex input series but never resample)
    ITER_CHUNK_SIZE = 200 # Queryset iteration batch size
    BULK_CREATE_BATCH_SIZE = 200 # Bulk create batch size

The Custom fields are strictly indexation axis.

You must not use them to store metadata or redundant data : these keys will be used to build Meta class unique_together and indexes. When you request a timeserie, all custom fields must be specified.

Following field names cannot be used : start_ts, data, dtype, updated_at, chunk_index

2/ Use your store class

# timeseries_usage.py
# Set one
attrs = {"version": 1, "kind": "type1"}
MyChunkedStore.set_ts(attrs, my_series)          # first write
MyChunkedStore.set_ts(attrs, delta_series, update=True)   # update (combine_first)
MyChunkedStore.set_ts(attrs, delta_series, replace=True)   # replace
MyChunkedStore.set_ts(attrs, delta_series)   # FAIL (attrs exists)

# Get one
full   = MyChunkedStore.get_ts(attrs)
window = MyChunkedStore.get_ts(attrs, start="2025-05-01", end="2025-05-31")
fail   = MyChunkedStore.get_ts({"version": 1})  # FAIL : must specify all attrs
none   = MyChunkedStore.get_ts({"version": 1, "kind": "nonexisting"})  # returns None : does not exists

# Set many
mapping = {
    (5, "type1"): series1,
    (5, "type2"): series2,
}
MyChunkedStore.set_many_ts(mapping, keys=("version", "kind"))

# Yield many
series_generator = MyChunkedStore.yield_many_ts({"version": 5})  # contains the 2 (serie, key_dict) from mapping

# CANNOT set many over existing
MyChunkedStore.set_many_ts(mapping, keys=("version", "kind")) # FAIL : at least one value from mapping already exists

3/ Define the ViewSet (server side)

# views.py
from hostore.utils.ts_sync import TimeseriesChunkStoreSyncViewSet

YearSync = TimeseriesChunkStoreSyncViewSet.as_factory(MyChunkedStoreServerSide, throttle_classes=[])  # pass ViewSet kwargs
router.register("ts/myendpoint", YearSync, basename="ts-myendpoint")

4/ Define the API (client side : pull new data)

# my_client_sync_module.py
from hostore.utils.ts_sync import TimeseriesChunkStoreSyncClient

client = TimeseriesChunkStoreSyncClient(
    endpoint="https://api.example.com/ts/myendpoint",
    store_model=MyChunkedStoreClientSide,
)
client.pull(batch=100)      # fetch new / updated chunks limiting one batch request to 100 items

(back to top)

Metadata

Release files for holcstore 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for holcstore 0.5.0
File Size Uploaded Provenance Actions
holcstore-0.5.0.tar.gz 38.4 kB With provenance Details for holcstore-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for holcstore 0.5.0
File Interpreter ABI Platform Actions
holcstore-0.5.0-py3-none-any.whl Python 3 none any Details for holcstore-0.5.0-py3-none-any.whl

Total release size: 89.6 kB

Release files / holcstore-0.5.0.tar.gz

Download URL holcstore-0.5.0.tar.gz
Size 38.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ddb8a23757df2ebd37fcfc315a4f885c0f00f2af212fe536bd00e13542862235
BLAKE2b-256 checksum
How to use checksums
81b0bda049cdb8491cc4228c6b3747d673af1723dc9755429419b8db2b9d096d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 4, 2025.

Transparency log

Release files / holcstore-0.5.0-py3-none-any.whl

Download URL holcstore-0.5.0-py3-none-any.whl
Size 51.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4bcc85ce0e28641e16600855f91585b87a5c2451965f932eef91bac122bd023e
BLAKE2b-256 checksum
How to use checksums
5f1a8fd97a307aef98b7595527af84f5e3741ebfc77c35227d1c31652e5110b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 4, 2025.

Transparency log

Security for holcstore 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for holcstore-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 4, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page