Skip to content
Queria Docs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Embed in shell pipelines

Pipe Queria CLI output to jq, and fetch data on a schedule from cron or CI

The Queria CLI lets you choose its output format with --format, so you can pipe its output to other commands. You can also run it from cron or CI to fetch data automatically.

Combine with jq

--format jsonl prints one JSON record per line, so jq can process it line by line.

queria sql "
  SELECT DISTINCT area_name, value AS population
  FROM e_stat.ssds.a_pref_population
  WHERE item_name = 'A1101_総人口' AND year = 2024
" --format jsonl | jq -r 'select(.population > 5000000) | .area_name'

To get all rows as a single array, use --format json.

queria list --format json | jq '.[].datasource'

Paste Markdown into documents

--format markdown prints a Markdown table that you can paste into READMEs, articles and PR descriptions.

queria sql "..." --format markdown >> report.md

Save on a schedule with cron

Put the date in the file name passed to --out, and each run leaves that day’s results in a file.

#!/usr/bin/env bash
set -euo pipefail
queria sql "
  SELECT area_name, value AS population
  FROM e_stat.ssds.a_pref_population
  WHERE item_name = 'A1101_総人口' AND year = 2024
" --out "snapshots/pop_$(date +%F).parquet"
0 6 * * 1 /home/you/bin/weekly-snapshot.sh

From CI

Pass your API token in the QUERIA_TOKEN environment variable (--token takes precedence over it). Reading without a token can hit the rate limits, so set a token for scheduled runs. In GitHub Actions:

env:
  QUERIA_TOKEN: ${{ secrets.QUERIA_TOKEN }}

See Authentication for issuing and managing tokens.

Notes

  • Save large results to a file with --out rather than printing them (the extension sets the format)
  • To compare with your local files, see Compare with your local data

Was this page helpful?