Commands
sqx runs a SQL query by default. A few subcommands handle prefetching, importing and the cache. Flags can go before or after positional arguments in every command.
| Command | What it does |
|---|---|
sqx [flags] "<SQL>" | Query stdin, -f files or a -db database |
sqx prefetch | Fetch URLs concurrently into the cache |
sqx import | Load files, stdin or URLs into a database file |
sqx cache | Inspect, query or clear the HTTP and DNS cache |
sqx tables / sqx schema | List tables with row counts, or show their CREATE statements |
sqx version | Print the version |
Run sqx -h to print the built-in help.
Query (default)
cat data.csv | sqx [flags] "<SQL>"
sqx -f users=users.csv -f events=events.jsonl "<SQL>"
sqx -db project.db "<SQL>"
This is what runs when the first argument is not a subcommand. You can also write sqx query … explicitly.
Statements that don't return rows (INSERT, UPDATE, CREATE, …) run as writes, and you can separate several with ;. INSERT … RETURNING prints the returned rows. All query flags and cache flags apply.
sqx prefetch
cat urls.txt | sqx prefetch -c 25 -timeout 10s
sqx prefetch https://example.com https://go.dev
SQLite evaluates functions one row at a time, so warm the cache with prefetch before running a query over hundreds of URLs. URLs come from arguments or stdin, one per line.
- Output columns:
url, final_url, status_code, response_ms, size_bytes, title, error. - Rows come back in input order, and duplicate URLs are fetched once.
-c <n>sets the number of workers (default10).-osets the output format.- Accepts all cache flags.
sqx crawlis an alias.
sqx import
sqx import -db analytics.db -t users users.csv
cat logs.jsonl | sqx import -db analytics.db -t logs
sqx import -db analytics.db -t countries https://example.com/countries.csv
sqx import -db analytics.db -t users -replace users.csv
| Flag | Default | Description |
|---|---|---|
-db <path> | sqx.db | Target SQLite database file |
-t <name> | data | Target table name |
-i <format> | auto | Input format: auto, csv, tsv, jsonl, json, lines |
-no-header | false | CSV/TSV input has no header row |
-replace | false | Drop the table first instead of appending |
import appends to an existing table and adds new columns automatically. The cache flags apply to URL sources.
sqx cache
sqx cache stats
sqx cache ls
sqx cache query "SELECT url, response_ms FROM http_cache ORDER BY response_ms DESC"
sqx cache clear -older-than 24h
sqx cache clear -all
| Action | What it does |
|---|---|
stats | URL and DNS counts, status breakdown, total body size |
ls | Every cached URL with status and timestamp |
query "<SQL>" | Run SQL against the http_cache and dns_cache tables |
clear -older-than <dur> | Remove HTTP and DNS entries older than a duration |
clear -all | Remove everything |
Also accepts -cache-db and -o. clear refuses to run without -all or -older-than. See The web cache.
sqx tables and sqx schema
sqx tables -db analytics.db
sqx schema -db analytics.db
tables lists every table with its row count. schema prints the CREATE statements. Both default to sqx.db and accept -o.
sqx version
sqx version
Prints the version, for example sqx v1.2.0. sqx -version does the same.