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.

CommandWhat it does
sqx [flags] "<SQL>"Query stdin, -f files or a -db database
sqx prefetchFetch URLs concurrently into the cache
sqx importLoad files, stdin or URLs into a database file
sqx cacheInspect, query or clear the HTTP and DNS cache
sqx tables / sqx schemaList tables with row counts, or show their CREATE statements
sqx versionPrint 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 (default 10). -o sets the output format.
  • Accepts all cache flags. sqx crawl is 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
FlagDefaultDescription
-db <path>sqx.dbTarget SQLite database file
-t <name>dataTarget table name
-i <format>autoInput format: auto, csv, tsv, jsonl, json, lines
-no-headerfalseCSV/TSV input has no header row
-replacefalseDrop 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
ActionWhat it does
statsURL and DNS counts, status breakdown, total body size
lsEvery 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 -allRemove 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.