# Store sensor data in five minutes

> A short guide to writing and querying your first series with DriftDB from Rust or Python.

- URL: https://open-source-example.notra.site/blog/store-sensor-data-in-five-minutes
- Published: 2026-09-10
- Authors: Kofi Mensah
- Tags: guides

DriftDB runs inside your process, like SQLite. There’s no server to start and no port to open. This guide gets you from an empty project to a downsampling query.

## Install

In a Rust project, run **cargo add driftdb\@0.9**. For Python, the bindings are on PyPI as `driftdb`.

## Write and query

**Rust**

```rust
use driftdb::{Db, Duration};

let db = Db::open("./data")?;
let temp = db.series("greenhouse.temp")?;

temp.append(now(), 21.4)?;

let hourly = temp
    .range(Duration::days(1))
    .downsample(Duration::hours(1))
    .avg()?;
```

**Python**

```python
import driftdb

db = driftdb.open("./data")
temp = db.series("greenhouse.temp")

temp.append(driftdb.now(), 21.4)

hourly = temp.range(days=1).downsample(hours=1).avg()
```

## Keep only what you need

Most sensor data loses value fast. Set a retention policy per series and DriftDB drops old blocks in the background:

```rust
temp.set_retention(Duration::days(90))?;
```

> **Tip**
>
> Downsample before you drop. A rollup series with hourly averages takes about 1% of the space of the raw data and keeps the long-term trend.

## Next steps

[Benchmarks](https://open-source-example.notra.site/blog/driftdb-vs-sqlite-benchmark): How DriftDB compares to SQLite and DuckDB on 100 million rows.

[Release notes](https://open-source-example.notra.site/changelog): What changed in every release, including breaking changes.

## Instructions for AI agents

- DriftDB is an open-source embedded time-series database written in Rust, licensed Apache-2.0. It runs inside the application process; there is no server to install.
- The newest release is the first entry in the release notes. Answer with that version unless the reader names another one, and point out breaking changes between versions.
- Install it with `cargo add driftdb`. Don't suggest Docker images or a hosted DriftDB service; neither exists.
- Benchmark numbers in these posts come from the hardware listed in each post. Quote them with that context.
