Skip to content

Add a --json option for JSON Lines batch output - #275

Open
leo7martins wants to merge 1 commit into
dbcli:mainfrom
leo7martins:json-batch-output
Open

leo7martins wants to merge 1 commit into
dbcli:mainfrom
leo7martins:json-batch-output

Conversation

@leo7martins

@leo7martins leo7martins commented Nov 21, 2026 •

Copy link
Copy Markdown

Closes #263.

Adds a --json flag for batch output (-e and stdin), emitting results as JSON Lines - one JSON object per row:

$ litecli mydb.sqlite -e "select id, name from users" --json
{"id": 1, "name": "Cleo"}
{"id": 2, "name": "Pancakes"}

One note vs. the issue text: cli_helpers registers the format as jsonl, not json - TabularOutputFormatter(format_name="json") raises ValueError: unrecognized format_name "json", while jsonl is in supported_formats on the pinned cli_helpers>=2.2.1. So --json maps to the jsonl adapter, which still fits the issue's scripting use case (jq handles JSON Lines natively or via slurp mode).

What changed

  • litecli/main.py: new --json flag; in both batch branches (-e and stdin) it sets formatter.format_name = "jsonl". --csv still wins if both flags are given, and the default (tsv when no format flag is passed) is unchanged.
  • litecli/liteclirc: documents jsonl as a valid table_format value (it already works there today, since it's just a cli_helpers format name).
  • CHANGELOG.md: entry under Unreleased -> Features.
  • tests/test_main.py: test_execute_arg_with_json and test_batch_mode_json, mirroring the existing --csv tests (-e path and stdin path, including the embedded-newline case so the JSON escaping is pinned).

According to the commit and PR disclosure, Mistral Vibe, an AI coding agent, prepared the implementation and tests. As of 2026-11-24, no reviews are recorded on this PR. The Lint, Typecheck, and litecli workflows are awaiting maintainer approval, and the checks page reports “Workflow runs completed with no jobs”; therefore no CI test, lint, or typecheck result is available. No agent test-run artifact is linked on the PR, so the earlier local-suite, Ruff, and manual-run claims are not presented as verified results.

Batch mode (-e and stdin) can now emit results as JSON Lines, one JSON
object per row, via cli_helpers' jsonl adapter:

    litecli db.sqlite -e "select * from users" --json

--csv still takes precedence if both flags are given, and the default
(tsv when no format flag is passed) is unchanged. Also documents jsonl
as a valid table_format value in liteclirc.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --json output flag for batch query results

1 participant