Persistent storage for energy portfolios β assets, grid topology, and 3-dimensional time series, in one connected database.
EnergyDB is a database for energy portfolios. It stores three things together in one connected system:
| Layer | Description | Real-World Example |
|---|---|---|
| π³Β Asset hierarchy | Arbitrary-depth tree of portfolios, sites, and assets | "Offshore-1 β WindTurbine T01 β power" |
| πΒ Grid topology | Typed edges (lines, transformers, pipes, interconnections) connecting any two assets | "Cable-1: BusA β BusB" |
| β±οΈΒ 3-dimensional time series | Actuals and versioned forecasts attached to any node or edge, queryable as-of any point in time | "power_flow on Cable-1, valid Wed 12:00, known Mon 18:00" |
Structure lives in PostgreSQL, values live in ClickHouse, and stable UUID identity lets Python objects round-trip to the database without losing any structural state.
EnergyDB extends TimeDB with persistent storage for EnergyDataModel hierarchies.
Most time-series systems are agnostic about what their series represent β they treat data as opaque (series_id, timestamp, value) triples. EnergyDB knows it is a portfolio, and links every series back to the asset or grid edge it describes.
- π Round-trip persistence: Every
Elementkeeps its UUID7 from in-memory object to row primary key β renames, moves, and property edits become silentUPDATEs, never delete-then-insert. - π Diffable structural changes:
dry_run=Truepreviews every insert, rename, move, and delete before you apply β no surprise data loss onreplace_subtree. - β±οΈ Time-of-knowledge queries: Forecast revisions, corrections, and as-of backtests, powered by TimeDB.
- π§ Lazy fluent navigation:
client.get_node("Portfolio", "Site", "T01").read(...)resolves to one indexed SQL query, regardless of subtree size. - βοΈ Unit conversion at the boundary: Declare canonical units once; pint rescales every read and write automatically.
pip install energydbRequires Python 3.12+, PostgreSQL (asset hierarchy + series catalog), and ClickHouse (time-series values).
from datetime import UTC, datetime
import energydb as edb
import pandas as pd
client = edb.Client() # reads TIMEDB_PG_DSN / TIMEDB_CH_URL
client.create()
# 1. Declare your portfolio: a tree of typed assets with their series.
t01 = edb.wind.WindTurbine(
name="T01", capacity=3.5, hub_height=80,
timeseries=[edb.TimeSeries(name="power", unit="MW",
data_type=edb.DataType.ACTUAL)],
)
portfolio = edb.Portfolio(
name="my-portfolio",
members=[edb.Site(name="Offshore-1", members=[t01])],
)
client.register_tree(portfolio) # create-only; edit existing nodes via scope mutators
# 2. Write hourly power for that turbine.
start = datetime(2026, 1, 1, tzinfo=UTC)
df = pd.DataFrame({
"valid_time": pd.date_range(start, periods=24, freq="1h", tz="UTC"),
"value": [2.5 + 0.05 * i for i in range(24)],
})
client.get_node("my-portfolio", "Offshore-1", "T01").write(
df, name="power", data_type="actual",
)
# 3. Read across the whole portfolio in one fluent call.
client.get_node("my-portfolio").read(name="power", data_type="actual")Want to try EnergyDB without a local setup? Open our Quickstart in Colab β the first cell automatically installs PostgreSQL + ClickHouse inside the VM.
Note: Data persists only within the active Colab session. Additional notebooks are available in the
examples/directory.
- π Official Documentation
- βοΈ Installation Guide
- π Python SDK Documentation
- π Reference
- π‘ Examples & Notebooks
| Project | Description |
|---|---|
| TimeDB | 3-dimensional time-series storage on ClickHouse with auditability and overlapping-forecast support |
| TimeDataModel | Pythonic data model for time series |
| EnergyDataModel | Data model for energy assets (solar, wind, battery, grid, ...) |
Contributions are welcome! If you're interested in improving EnergyDB, 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.