query-forge
Rust CLI to run SQL queries on one or more XLSX/XML/CSV/JSON/JSONL/Markdown inputs and produce output in text, CSV, JSONL, Markdown, XML, or a new XLSX file.
Installation
From crates.io:
From source (local development):
Quick start
Run an inline query:
Or load the query from an SQL file:
Key features
- SQL queries on XLSX/XML/CSV/JSON/JSONL/Markdown data using in-memory SQLite.
- Multi-file support with automatic table mapping:
table/table1,table2,table3, ... - Explicit table naming:
name=file.xlsxassigns a custom SQL table name for readability. - Sheet selection with
file.xlsx:SheetNameorfile.xlsx#SheetName. - For XML inputs, if no sheet/tag is provided the whole file is used; if a sheet is provided, only the subtree inside that XML tag is used.
- CSV, JSON, JSONL and Markdown inputs are supported directly (
.csv,.json,.jsonl,.md,.markdown) and can be mixed with XLSX/XML in the same query. - In
qf query, sheet/tag/key selection is expressed viafile:selectororfile#selector(XLSX, XML, JSON, Markdown; for Markdown, selector is 1-based table index); CSV/JSONL do not support selector syntax. - Named SQL parameters from CLI with
--param. - Output export in
txt,csv,jsonl,markdown,xml,xlsx. - Support for headerless sheets with
--no-headers(column1,column2, ...).
Examples
Multiple inputs
Explicit table names
Assign readable names to each input for use in SQL queries:
Without a name prefix, tables are automatically named table, table2, table3, etc.
Parameterized query
SELECT *
FROM table
WHERE "Elemento WBS" LIKE '%' || :wbs || '%'
AND CAST("ore" AS REAL) > :min_ore;
Parameters:
Multiple values for the same parameter (separated by , or ;):
XML input
Use the whole XML file:
Use only a specific XML tag as sheet:
CSV/JSON/JSONL/Markdown input
CSV:
JSONL:
JSON (array at root):
JSON with key selection as sheet:
Markdown (first table by default):
Markdown with table index key (second table):
Export
CSV:
JSONL:
Markdown:
XML:
XLSX:
Ready-to-use examples
The examples/ folder contains:
inventory.xlsx,inventory.xml,inventory.csv,inventory.json,inventory.jsonl,inventory.mdas inputs.active-products.txt,active-products.csv,active-products.jsonl,active-products.md,active-products.xml,active-products-from-xml.csv,active-products-from-csv.csv,active-products-from-json.csv,active-products-from-jsonl.csv,active-products-from-markdown.csv,stock-by-category.xlsxas generated outputs.commands.shwith runnable commands from the repository root.
Regenerate the examples locally:
Documentation
- Crate: https://crates.io/crates/query-forge
- API docs: https://docs.rs/query-forge
- Repository: https://github.com/mad4j/query-forge
- Roadmap: ROADMAP.md
Comparison
query-forge is designed as a focused CLI for running SQL queries across heterogeneous local files with a uniform --input model. Nearby tools exist, but they usually cover only part of the same problem.
| Tool | SQL queries | XLSX | XML | CSV | JSON/JSONL | Markdown tables | Primary focus |
|---|---|---|---|---|---|---|---|
query-forge |
Yes | Yes | Yes | Yes | Yes | Yes | Unified SQL CLI over heterogeneous document-style inputs |
duckdb |
Yes | Partial | Partial | Yes | Yes | No | General-purpose analytical SQL engine |
csvkit |
Partial | Via conversion | No | Yes | Limited | No | CSV tooling and CSV-oriented SQL workflows |
qsv / xsv / miller |
Limited / No | No | No | Yes | Limited | No | Fast tabular text processing |
jq |
No | No | No | No | Yes | No | JSON transformation and filtering |
xmlstarlet |
No | No | Yes | No | No | No | XML querying and transformation |
VisiData |
Partial / Interactive | Yes | Limited | Yes | Yes | Limited | Interactive data exploration |
Notes:
duckdbis the closest alternative when the core requirement is "run SQL on local data files", especially for CSV and JSON, but it does not provide the same single-purpose workflow for XLSX/XML/Markdown inputs.csvkit,qsv,xsv, andmillerare strong tabular-data tools, but they are centered on delimited text rather than a unified multi-format SQL interface.jqandxmlstarletare powerful for JSON and XML respectively, but they use format-specific query languages instead of SQL.VisiDatais excellent for interactive inspection, whilequery-forgeis oriented to batch execution and scriptable SQL queries.
License
Released under the MIT license. See LICENSE.