CLI tool that loads CSV/TSV/JSON/NDJSON/XML data into in-memory SQLite, executes SQL queries, outputs results in multiple formats (CSV, TSV, JSON, NDJSON, XML, Markdown, HTML, SQL INSERT, pretty table). Single binary, zero external dependencies, bundled SQLite.
src/main.zig— CLI entry point, argument parsing, mode dispatch, I/O setupbuild.zig— Zig build system with 120+ integration tests
| Directory | Responsibility Summary | Detailed Map |
|---|---|---|
src/ |
Core pipeline: argument parsing, input loading, SQLite execution, output formatting | View Map |
src/modes/ |
Sub-command implementations (--columns, --validate, --sample, --schema, --stats) |
View Map |
tests/fixtures/ |
Sample CSV/JSON/NDJSON/XML files for integration tests | (fixtures only) |
lib/ |
Bundled SQLite amalgamation (sqlite3.c, sqlite3.h) | (vendored C) |
stdin / file(s)
│
▼
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Input Loaders │────▶│ In-memory SQLite │────▶│ Output Formatters│
│ (csv, json, │ │ (sqlpipe_* tables)│ │ (csv, json, │
│ ndjson, xml) │ │ │ │ table, md, etc)│
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │ │
│ ┌────┴────┐ │
│ │ SQL │ │
│ │ Query │ │
│ └────┬────┘ │
│ ▼ │
└──────────────────▶ stdout/stderr ◀───────────────┘
- Single binary, zero deps — Bundles SQLite amalgamation; no external dependencies
- Streaming I/O — Buffered readers, no full-file buffering (except XML/JSON which need full parse)
- Type inference — Samples first N rows (default 1000) to infer SQLite column types
- Mode pattern — Each sub-command (
--columns,--validate, etc.) is a separate module insrc/modes/ - Zig 0.16
std.Io— Uses newstd.Io.Reader/Writerabstractions with buffered file I/O - Arena allocators — Used for temporary allocations during query execution
- Error handling —
fatal()helper prints to stderr and exits with typedExitCode
- CLI args →
src/args.zig→ parsed intoParsedArgs+ mode-specific structs - Input formats →
format.InputFormatenum → dispatcher inloader.loadInput() - Output formats →
format.OutputFormatenum → dispatcher informat.writeOutput() - SQLite →
src/sqlite.zigwraps C API; all SQL errors →fatal()withExitCode.sql_error
zig build test— 120+ integration tests (bash-based) + XML unit testszig build unit-test— CSV loader unit tests with leak detectionziglint src build.zig— Linting