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

Embed in shell pipelines

Automate data retrieval by piping Queria CLI output into jq, cron, and CI

The Queria CLI switches its stdout format with --format, so it drops straight into Unix pipes, cron, and CI. The shell tooling you already use works as-is, from ad-hoc analysis to automated data retrieval.

Combine with jq

--format jsonl emits one JSON record per line, which pairs well with stream processing:

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'

Use --format json when you want a single array of records:

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

Paste Markdown into documents

--format markdown output pastes straight into READMEs, articles, and PR descriptions:

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

Periodic snapshots with cron

Write to --out with a dated filename and snapshots accumulate for fixed-point observation:

#!/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 via the QUERIA_TOKEN environment variable (the --token flag overrides it). Anonymous access is rate-limited, so a token is recommended for scheduled runs. With GitHub Actions:

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

See Authentication for issuing and managing tokens.

Good to know

  • Write large results to --out instead of stdout (the extension decides the format)
  • For joining with your local files, see Combine with your local data

Was this page helpful?