Guides

Report on a dataset

Load a public dataset into DuckDB, chart it in SQL, and share a link to the dashboard.

Recipe: DuckDB

You want the answer to a question about some data as a dashboard you can send, not a table in chat. The agent loads the data into DuckDB, writes the dashboard in SQL and gives you a link. Here: where the world's electricity comes from, from Our World in Data. First, connect your agent.

Ask

Start DuckDB on briq, load 'Our World in Data' energy dataset into it, generate a report on world energy generation, and share it with me.

What the agent does

1. Start the briq. One recipe, one briq: DuckDB inside Shaper, a dashboard tool, already set up. expose: "private" gives it a URL only whoever has it can open.

briq_run({ recipe: "duckdb", stack: "reports", expose: "private" })
→ duckdb running · url: https://duckdb-r4tq.briq.run/?briq_token=…

2. Load the data. Through briq_exec in the duckdb briq, where shp runs SQL. DuckDB downloads the file itself, so the data never goes through the agent. One row per country and year, and some 130 measures: electricity by source in TWh (fossil_electricity, nuclear_electricity, renewables_electricity, solar_electricity…), their shares in %, energy use.

shp sql "CREATE TABLE energy AS FROM read_csv('https://raw.githubusercontent.com/owid/energy-data/master/owid-energy-data.csv')"

Rows without an iso_code are aggregates (World, continents, income groups): country = 'World' gives the totals, iso_code IS NOT NULL keeps the countries. World figures run to 2025.

3. Write the dashboard. One SQL file: each SELECT is a chart, and its casts say how to draw it. Sent as stdin of ["shp", "dashboard", "Energy", "-"], which prints the dashboard's id:

SELECT 'Where the world''s electricity comes from'::SECTION;

SELECT 'World generation by source (TWh)'::LABEL;
SELECT make_date(year::INT, 1, 1)::XAXIS, source::CATEGORY, twh::LINECHART FROM (
  UNPIVOT (SELECT year, fossil_electricity AS fossil, nuclear_electricity AS nuclear,
                  renewables_electricity AS renewables
           FROM energy WHERE country = 'World' AND year >= 1985)
  ON fossil, nuclear, renewables INTO NAME source VALUE twh
) ORDER BY ALL;

SELECT 'Largest producers, 2025 (TWh)'::LABEL;
SELECT country::XAXIS, source::CATEGORY, twh::BARCHART_STACKED FROM (
  UNPIVOT (SELECT country, electricity_generation AS total, fossil_electricity AS fossil,
                  nuclear_electricity AS nuclear, renewables_electricity AS renewables
           FROM energy WHERE iso_code IS NOT NULL AND year = 2025
           ORDER BY total DESC NULLS LAST LIMIT 12)
  ON fossil, nuclear, renewables INTO NAME source VALUE twh
) ORDER BY ALL;

More charts in the same file: solar and wind against hydro, the low-carbon share of the largest producers, renewables' share country by country.

4. Share it. A public dashboard is read-only and needs no account:

shp share 4f9k2…
→ /view/4f9k2…

The link to send is the briq's private URL with that path: https://duckdb-r4tq.briq.run/view/4f9k2…?briq_token=…. briq turns away every request without the token before it reaches the briq, so only people with the link see the report.

Good to know

  • The first chart is ready in under a minute: the briq starts in about 20 seconds and the load takes a few.
  • Polish it by hand at URL, signed in with SHAPER_ADMIN_EMAIL and SHAPER_ADMIN_PASSWORD: the editor shows the SQL beside the dashboard.
  • Fresh data, same dashboard: run the load again with CREATE OR REPLACE TABLE; every chart runs its query on each view.
  • A PDF to attach: ["shp", "pdf", "4f9k2…", "/tmp/energy.pdf"], then briq_files_get.
  • Withdraw the link with briq_expose({ briq, port: 5454, rotate: true }): the URL stays, the old token stops working. Destroy the briq when the report has served its purpose.
  • A BI tool with a visual editor: the metabase recipe runs Metabase on a Postgres warehouse.

On this page

Free to try

Try briq, on us.

Every new account starts with €10 of credits. No card.

Start building

How can we help?

Message to the briq team