A tool for managing Heroku Dataclips programmatically.
Dataclips are a great tool for BI and data analysis tasks on top of Heroku
Postgres, but are limited by their web-only interface. With dataclips-cli
you
can easily manage these queries as flat files instead, enabling dataclips
updates as part of a CI workflow, tracking revision history, etc.
Requires deno and the Heroku CLI;
First, create a dataclip via the web
interface. It will have a URL similar to
https://data.heroku.com/dataclips/vgntjcbwfakfsxhdmrmzmliwftts
.
vgntjcbwfakfsxhdmrmzmliwftts
is the "slug" of the dataclip.
Queries should be stored as flat .sql
files, with a little metadata at the
beginning. Here's an example.
$ cat example.sql
-- clip_slug: vgntjcbwfakfsxhdmrmzmliwftts
-- title: A Test Dataclip
select count(*) from pg_user;
# Update some query files
$ deno run --allow-read --allow-env --allow-net https://deno.land/x/dataclips_cli/index.ts file.sql file2.sql
dataclips-cli reads your Heroku API key from ~/.netrc
(where the Heroku CLI
writes it), or uses the environment variable HEROKU_API_KEY
if available, e.g:
$ HEROKU_API_KEY=mykey deno run ... etc
Uses version for version management
$ deno run -A https://deno.land/x/version/index.ts patch
$ git push --follow-tags
— will be automatically deployed to https://deno.land/x/dataclips_cli
This tool was created by emulating Heroku's browser APIs. It's not officially supported or endorsed by Heroku, and may break at any time. Community participation in keeping it running is strongly encouraged.
MIT