Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ sudo rpm -i https://github.com/vmvarela/sql-pipe/releases/latest/download/sql-pi

Replace `VERSION` with the release version (e.g. `0.2.0`) and `x86_64` with your architecture (`aarch64`).

**Alpine Linux (.apk package):**

```sh
wget https://github.com/vmvarela/sql-pipe/releases/latest/download/sql-pipe_VERSION_x86_64.apk
sudo apk add --allow-untrusted sql-pipe_VERSION_x86_64.apk
```

Replace `VERSION` with the release version (e.g. `0.2.0`) and `x86_64` with your architecture (`aarch64`).

**Arch Linux (AUR):** install with your preferred AUR helper:

```sh
Expand Down Expand Up @@ -138,6 +147,15 @@ $ cat data.tsv | sql-pipe --tsv 'SELECT * FROM t'
$ cat data.tsv | sql-pipe --delimiter '\t' 'SELECT * FROM t'
```

Output results as a JSON array of objects with `--json`:

```sh
$ printf 'name,age\nAlice,30\nBob,25' | sql-pipe --json 'SELECT * FROM t'
[{"name":"Alice","age":30},{"name":"Bob","age":25}]
```

`--json` is mutually exclusive with `-d`/`--delimiter`, `--tsv`, and `-H`/`--header`.

Chain queries by piping back in — useful for two-pass aggregations:

```sh
Expand All @@ -154,6 +172,7 @@ $ cat events.csv \
| `--tsv` | Alias for `--delimiter '\t'` |
| `--no-type-inference` | Treat all columns as TEXT (skip auto-detection) |
| `-H`, `--header` | Print column names as the first output row |
| `--json` | Output results as a JSON array of objects (mutually exclusive with `-d`, `--tsv`, `-H`) |
| `-h`, `--help` | Show usage help and exit |
| `-V`, `--version` | Print version and exit |

Expand Down
17 changes: 15 additions & 2 deletions docs/sql-pipe.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SYNOPSIS
DESCRIPTION
sql-pipe reads CSV data from standard input, loads it into an in-memory SQLite
database table named *t*, executes the provided SQL query, and prints the results
as CSV to standard output.
as CSV (or JSON when *--json* is used) to standard output.

This tool is useful for quick data transformations, filtering, grouping, and
aggregations on CSV files without manual SQL database setup.
Expand Down Expand Up @@ -44,7 +44,13 @@ OPTIONS
Print a header row with column names as the first line of output. Column
names are taken from the SQL column alias or original name. The output
remains valid CSV that can be piped back into sql-pipe. Header output is
off by default.
off by default. Cannot be combined with *--json*.

*--json*
Output results as a JSON array of objects instead of CSV. Each row
becomes a JSON object with column names as keys and typed values (string,
number, or null). Mutually exclusive with *--delimiter*, *--tsv*, and
*--header*.

*-h, --help*
Print the help message and exit with code 0.
Expand Down Expand Up @@ -89,6 +95,13 @@ EXAMPLES

$ cat data.tsv | sql-pipe --tsv 'SELECT \* FROM t'

Output results as JSON:

$ printf 'name,age\nAlice,30\nBob,25' | sql-pipe --json 'SELECT \* FROM t'

Output:++
[{"name":"Alice","age":30},{"name":"Bob","age":25}]

EXIT CODES
*0*
Success: query executed successfully and results were output.
Expand Down
Loading