Dashboards with DuckDB, written in SQL and Markdown
A Dash dashboard is a Markdown file with SQL blocks. Each block shows its result as a chart, a table or a dropdown that filters other blocks. The queries run on DuckDB in your browser, so your data stays on your machine.
- 01
Add your data
Drop a CSV, Parquet, JSON or Excel file into Dash, or open a DuckDB file. You can also query a file by its URL.
SELECT * FROM 'https://example.org/services.parquet'
- 02
Write a block for each chart
The view line of a sql block sets how its result is shown. Pages have bar, line, area, scatter, pie and radar charts, tables and single numbers.
```sql busiest_stations -- view: bar -- x: StationName -- y: stops SELECT StationName, count(*) AS stops FROM 'services.parquet' GROUP BY ALL ORDER BY stops DESC LIMIT 10 ```
- 03
Filter with a dropdown
A block with the select view shows a dropdown. Other blocks read the picked values with refs.<name>() and run again when the pick changes.
```sql service_type -- view: select -- column: ServiceType SELECT DISTINCT ServiceType FROM 'services.parquet' ``` ... WHERE ServiceType IN (SELECT ServiceType FROM refs.service_type()) - 04
Arrange the blocks
Write text between the blocks to explain the numbers, and use columns to put charts side by side. The dashboard stays one Markdown file, so you can keep it in git.
<columngroup> <column span="7"> ...chart... </column> <column span="5"> Utrecht Centraal is the busiest station. </column> </columngroup>
Questions
- Does a dashboard in Dash need a server?
- No. In the browser, DuckDB WASM runs the queries inside the page and your files never leave your machine. The desktop app and the DuckDB extension use native DuckDB instead.
- Can I build a dashboard from a Parquet or CSV file?
- Yes. Drop the file into Dash or query it by its path or URL. DuckDB reads CSV, Parquet, JSON and Excel files directly.
- Can I use my own DuckDB database?
- Open the .duckdb file in Dash, or run Dash inside your own DuckDB with the community extension: INSTALL dash FROM community; LOAD dash; PRAGMA dash;
- Is Dash free?
- Dash is open source under the AGPL-3.0 license and free to use.