---
title: Embed in shell pipelines
description: 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.

```bash
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`.

```bash
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.

```bash
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.

```bash
#!/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"
```

```text
0 6 * * 1 /home/you/bin/weekly-snapshot.sh
```

:::note
cron runs with almost nothing on PATH. Call the `queria` installed by `uv tool install queria` by its full path, or set PATH at the top of the script.
:::

## 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](/en/limits), so set a token for scheduled runs. In GitHub Actions:

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

See [Authentication](/en/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](/en/recipes/local-data)
