Skip to content

Data model

Storage

  • File: rainlog.sqlite (constant DEFAULT_DB_FILE_NAME in rainlog)
  • Default location: ~/.local/share/rainlog/rainlog.sqlite (constant DEFAULT_DB_DIR)
  • Override: rainlog --db-dir <path> puts the file in the given directory.
  • Engine: SQLite3, table created automatically:
CREATE TABLE IF NOT EXISTS rain_daily (
  date INT NOT NULL UNIQUE PRIMARY KEY,
  rain REAL
)
  • date column: Unix timestamp (seconds) for the end of the 24-hour period, normalised to 09:00:00 local time (i.e. the reading covers the 24 h ending at 09:00 on the stored calendar day).
  • rain column: Millimetres (mm).

Semantics

  • One row per logical day (unique date bucket).
  • get_rain aggregates raw rows by GraphGrouping (daily, weekly, monthly, yearly, annually) for the TUI chart.
  • get_moisture_index computes an exponentially decaying moving sum used in soil-moisture chart mode.

Coverage convention

rainlog assumes every calendar day has an explicit record. A day with no rain is stored as 0.0, not as a missing row. This complete-coverage invariant is what makes streak detection, averages, and percentile comparisons meaningful.

The Back-fill zeros toggle in the Add Rain modal (on by default) enforces this: when you log a reading after a gap, it automatically inserts 0.0 rows for every day between the previous record and the new one. As long as you use backfill consistently, the database stays complete.

Time zone

Bucket boundaries use the host's local time zone at runtime (LOCAL_TZ in rainlog).

See also