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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,19 @@ $ printf 'name,age\nAlice,30\nBob,25' | sql-pipe -O xml 'SELECT * FROM t'
$ cat data.xml | sql-pipe -I xml 'SELECT name FROM t WHERE age > 25'
```

Real-world XML documents (RSS feeds, API responses) nest rows inside a container element. Use `--xml-root` to navigate to the row container and `--xml-row` to filter by element tag:

```sh
# Query an RSS feed: channel/item → rows
$ curl -s https://feeds.feedburner.com/TheHackersNews \
| sql-pipe -I xml --xml-root channel --xml-row item \
'SELECT title FROM t LIMIT 5'

# Query XML with a custom root and row name
$ cat events.xml | sql-pipe -I xml --xml-root events --xml-row event \
'SELECT name, date FROM t WHERE type = "conference"'
```

Chain queries by piping back in — useful for two-pass aggregations. Pass `-H` to the first call so the second one sees column names:

```sh
Expand Down
10 changes: 10 additions & 0 deletions docs/sql-pipe.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ EXAMPLES

$ cat data.xml | sql-pipe -I xml 'SELECT name FROM t WHERE age > 25'

Query XML input with nested structure using --xml-root and --xml-row (e.g. RSS feeds):

$ curl -s https://feeds.example.com/news.rss \
| sql-pipe -I xml --xml-root channel --xml-row item 'SELECT title FROM t LIMIT 5'

Output results as XML with custom element names:

$ cat data.csv \
| sql-pipe -O xml --xml-root feed --xml-row entry 'SELECT * FROM t'

Preview schema and first 3 rows of a CSV file:

$ cat sales.csv | sql-pipe --sample 3
Expand Down
1 change: 1 addition & 0 deletions src/args.zig
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ pub fn printUsage(writer: *std.Io.Writer) !void {
\\ cat data.csv | sql-pipe --output-format json 'SELECT * FROM t'
\\ cat data.json | sql-pipe --input-format json 'SELECT * FROM t'
\\ cat data.ndjson | sql-pipe -I ndjson -O ndjson 'SELECT name FROM t WHERE age > 18'
\\ cat data.xml | sql-pipe -I xml --xml-root channel --xml-row item "SELECT title FROM t"
\\ cat data.csv | sql-pipe --sample 5
\\
);
Expand Down
Loading