For the complete documentation index, see llms.txt. This page is also available as Markdown.

TimescaleDB

TimescaleDB is a category-defining relational database for time-series data. Packaged as a PostgreSQL extension, TimescaleDB is designed to be easy to use, easy to get started, and easy to maintain.

Download this sample dataset by Timescale

Docker Compose

mkdir /tmp/prest+timescaledb
cd /tmp/prest+timescaledb
cat <<YML > docker-compose.yml
---
version: "3"
services:
  timescaledb:
    image: timescale/timescaledb:latest-pg12
    volumes:
      - "./data:/var/lib/postgresql/data"
      - "/tmp:/var/tmp"
    environment:
      - POSTGRES_USER=prest
      - POSTGRES_DB=prest
      - POSTGRES_PASSWORD=prest
    ports:
      - "5432:5432"
  prest:
    image: prest/prest:v2.0.0
    links:
      - "timescaledb:timescaledb"
    environment:
      - PREST_VERSION=2
      - PREST_DEBUG=true  # remove comment for enable DEBUG mode (disable JWT)
      - PREST_PG_HOST=timescaledb
      - PREST_PG_USER=prest
      - PREST_PG_PASS=prest
      - PREST_PG_DATABASE=prest
      - PREST_PG_PORT=5432
      - PREST_JWT_DEFAULT=false  # remove if need jwt
      - PREST_PG_SSL_MODE=disable
    depends_on:
      - timescaledb
    ports:
      - "3000:3000"
YML

v2 notes: examples use prest/prest:v2.0.0 with PREST_VERSION=2. When JWT enforcement is enabled (PREST_JWT_DEFAULT=true or equivalent), configure PREST_JWT_KEY (or PREST_JWT_JWKS / PREST_JWT_WELLKNOWNURL) explicitly — or expect JWT to be auto-disabled with a warning in v2.0.0. The v2.0.0-rc6 tagged binary refuses to start without verification material. See Deploying with Docker and Configuring pREST.

Starting up the containers

Creating database structure

Loading data

Simple Query

SQL execution:

prestd execution:

Joining tables

SQL execution:

prestd execution:

Using VIEWs

Creating VIEW named battery_level_by_hour:

Aggregating data over battery_level_by_hour view:

prestd execution:

Simple SELECT over battery_level_by_hour view:

**prestd execution over battery_level_by_hour view:

Batch Insert data

Using default INSERT statement WITH returning inserted data:

Using COPY statement WITHOUT returning inserted data:

Last updated