Skip to main content

Minimal stateless ClickHouse library for bitemporal time series

Project description

⏱️ TimeDB

An open-source, opinionated time-series database built on PostgreSQL & ClickHouse.

PyPI Python Versions License Slack


TimeDB is designed to natively handle overlapping forecast revisions, auditable human-in-the-loop updates, and "time-of-knowledge" history. Using a three-dimensional temporal data model, it provides a seamless workflow through its Python SDK and FastAPI backend.

Traditional time-series databases assume one immutable value per timestamp. TimeDB is built for complex, real-world domains where forecasts evolve, data gets corrected, and historical backtesting requires strict audits.


🧊 The 3D Temporal Data Model

At the heart of TimeDB is its three-dimensional approach to time. We track not just when data is valid, but when it became known and when it was altered.

Dimension Description Real-World Example
📅 valid_time The time the value represents a fact for. "Wind speed forecast for Wednesday 12:00"
⏰ knowledge_time The time when the value was predicted/known. "Generated on Monday 18:00"
✏️ change_time The time when the value was written or changed. "Manually overridden on Tuesday 09:00"

Audit & Metadata: Every data point also supports tags, annotations, and changed_by to maintain a perfect audit trail of who changed what, when, and why.


✨ Why Choose TimeDB?

  • 📊 Forecast Revisions: Store overlapping forecasts with full provenance.
  • 🔄 Auditable Updates: Manual adjustments generate audit trails, not silent overwrites.
  • True Backtesting: Query historical data as of any point in time ("What did our model know last Monday?").
  • 🏷️ Label-Based Organization: Easily filter and slice series by meaningful dimensions.

TimeDB demo

🚀 Quick Start

1. Installation

pip install timedb

Requires Python 3.9+, PostgreSQL (series metadata), and ClickHouse (time-series values).

2. Usage Example

import timedb as td
import pandas as pd
from datetime import datetime, timezone
from timedb import TimeSeries

# Create Schema
td.create()

# 1. Create a forecast series
td.create_series(
    name="wind_power",
    unit="MW",
    labels={"site": "offshore_1"},
    overlapping=True
)

# 2. Insert forecast with knowledge_time
knowledge_time = datetime(2025, 1, 1, 18, 0, tzinfo=timezone.utc)
ts = TimeSeries.from_pandas(
    pd.DataFrame({
        'valid_time': pd.date_range('2025-01-01', periods=24, freq='h', tz='UTC'),
        'value': [100 + i*2 for i in range(24)]
    }),
    unit='MW',
)

td.get_series("wind_power") \
   .where(site="offshore_1") \
   .insert(ts, knowledge_time=knowledge_time)

# 3. Read latest forecast — returns a TimeSeries
ts_latest = td.get_series("wind_power").where(site="offshore_1").read()
df_latest = ts_latest.to_pandas()  # pd.DataFrame with valid_time index

# 4. Read forecast history (one row per knowledge_time × valid_time)
ts_all = td.get_series("wind_power").where(site="offshore_1").read(overlapping=True)

🧪 Try it in Google Colab

Want to try TimeDB without a local setup? Open our Quickstart in Colab — the first cell automatically installs PostgreSQL + ClickHouse inside the VM.

Open In Colab

Note: Data persists only within the active Colab session. Additional notebooks are available in the examples/ directory.


📚 Documentation & Resources


🤝 Contributing

Contributions are welcome! If you're interested in improving TimeDB, please see our Development Guide for local setup instructions.


Licensed under the Apache-2.0 License.

Find a bug or have a feature request? Open an Issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

timedb-0.2.1.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

timedb-0.2.1-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file timedb-0.2.1.tar.gz.

File metadata

  • Download URL: timedb-0.2.1.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for timedb-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b133b4320d419efb472723bb466c3bc38b9660366c60e57f0375089094a55e53
MD5 040f45b6689c802b0fc106a5b1a93ba9
BLAKE2b-256 0e494167740325cefcada5ef969f1b8787f0d6c17708da5d3a21d9de452d8153

See more details on using hashes here.

Provenance

The following attestation bundles were made for timedb-0.2.1.tar.gz:

Publisher: publish.yml on rebase-energy/timedb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file timedb-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: timedb-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for timedb-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 095a90ccbb1eff8daa221773bd924180a7da69bff880ebf5b50a5e09c114a214
MD5 d2391613ad26b261fd889ebb275978a6
BLAKE2b-256 6c29ac8fd26a824906dc65a2b88b51bd3e7497d911a7f99f99cca7db11ded24d

See more details on using hashes here.

Provenance

The following attestation bundles were made for timedb-0.2.1-py3-none-any.whl:

Publisher: publish.yml on rebase-energy/timedb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page