025: DuckDB (analytics)

A Piko project that uses DuckDB for in-process analytical queries. DuckDB is well suited to dashboards that run aggregate queries over millions of rows without a separate database process.

What this demonstrates

  • The WithDatabase bootstrap option with the DuckDB driver.
  • Columnar-store query patterns (aggregates, GROUP BY, and strftime date formatting).
  • Seeding sample sales data via a SQL migration (db/migrations/001_sales.up.sql) that is applied at startup.
  • A dashboard page that runs multiple aggregate queries and renders summary cards and tables.

Project structure

src/
  cmd/
    main/main.go        Bootstrap with WithDatabase("sales", ...).
    generator/main.go   Per-project generator entry point.
  db/
    queries/sales.sql   Annotated SQL files for the querier generator.
    migrations/         Schema migrations (001_sales.up.sql).
    generated/          Type-safe querier output.
  pages/
    index.pk            Dashboard page.

How to run this example

From the Piko repository root:

cd examples/scenarios/025_database_duckdb/src/
go mod tidy
go run ./cmd/generator/main.go all
air

See also