Skip to content

Instantly share code, notes, and snippets.

@jorinvo
Created May 26, 2026 01:57
Show Gist options
  • Select an option

  • Save jorinvo/afae84a0ef12701e733c7d465b257617 to your computer and use it in GitHub Desktop.

Select an option

Save jorinvo/afae84a0ef12701e733c7d465b257617 to your computer and use it in GitHub Desktop.
download_dashboard.sql
INSTALL http_client FROM community;
LOAD http_client;
-- Generate key with `dashboard:read` permission in Admin UI
SET VARIABLE shaperkey = 'myshaperkey';
-- Returns file as BLOB
CREATE TEMP MACRO download_dashboard(id, ext) AS
(SELECT content FROM read_blob(concat('http://localhost:5454', http_get(
concat('http://localhost:5454/api/dashboards/', id, '/download/result.', ext, '?mode=url'),
headers => MAP {
'Authorization': concat('Bearer ', getvariable('shaperkey')),
'Accept': 'application/json'
},
MAP {}
)->>'body'->>'url')));
SELECT download_dashboard('mydashboardid', 'pdf');
SELECT download_dashboard('mydashboardid', 'png');
SELECT download_dashboard('mydashboardid', 'xlsx');
SELECT download_dashboard('mydashboardid', 'csv');
SELECT download_dashboard('mydashboardid', 'json');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment