Get started¶
iq runs jq1 filters to query, dump, copy, diff and write data across NoSQL
databases, and their dump files, from a single static binary. See
Drivers for supported databases.
iq normalizes fetched values to JSON. The filter runs entirely client-side,
so one filter means the same thing everywhere.
The URI scheme2 chooses the backend. The filter is both the transform and
the key selector. The selector walks the parsed jq AST5. Based on the
AST, the selector executes a bounded read, a streaming scan (with
pushdown6), or a materialized scan (see
How it works).
Typed dumps carry native types across stores. As a result, a copy, a restore or a migration is one command instead of an export plus a conversion script.
iq is inspired by sq, whose command set it
deliberately follows.
Note
iq is built with AI assistance, and every change passes the full test
suite, container-backed integration tests for every backend, and a mutation
gate before it lands (see
CONTRIBUTING.md).
Queries are read-only. --insert, --replace, iq data clear,
iq data drop and iq data delete write to the target. iq exec forwards
a native command to the database, so it can write too. Use --explain to
see the query plan or --dry-run to report the
effect of a write, without changing anything. iq exec has no dry run.
Feedback and bug reports are very welcome. Report security problems privately, see the security policy.
Installation¶
iq ships as a single static binary (no runtime dependencies, no CGO3).
Version & Location
The script downloads the release for your OS/arch, verifies its SHA-2564
against the release checksums, and installs the binary. IQ_VERSION
pins a version and IQ_INSTALL_DIR picks the target directory.
You can also download a .deb, .rpm, .apk, or Arch .pkg.tar.zst from the
releases.
Verify a release¶
Every release signs checksums.txt with a keyless cosign
signature from the release workflow, and carries SLSA build provenance for every
artifact (multiple.intoto.jsonl). The install script checks the SHA-256 of the
archive it downloads. To check a download yourself, first make sure that
checksums.txt comes from the iq release workflow:
cosign verify-blob checksums.txt \
--bundle checksums.txt.sigstore.json \
--certificate-identity-regexp '^https://github.com/zsltg/iq/\.github/workflows/release\.yml@refs/tags/v' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
sha256sum --ignore-missing -c checksums.txt
To check the build provenance of an archive, use slsa-verifier:
slsa-verifier verify-artifact iq_0.37.1_linux_amd64.tar.gz \
--provenance-path multiple.intoto.jsonl \
--source-uri github.com/zsltg/iq --source-tag v0.37.1
Releases before v0.37.1 carry checksums.txt only, with no signature or
provenance.
Building from source¶
The basics¶
Register a source for each store you work with. Then make one of them active:
iq add -n orders 'mongodb://localhost:27017/shop?collection=orders'
iq add -n staging 'mongodb://staging:27017/shop?collection=orders'
iq add -n cache redis://localhost:6379/0
iq add -n snap file:///backups/prod.rdb
iq src orders
iq --src orders '.[] | select(.status == "new") | {id, total}'
You can find detailed examples in Sources, Query data and Write data.
For more advanced usage check Output, Query plan, Cookbook and Loading exports.
For debugging, see Diagnostics & Logging.
Supported data sources are listed in Drivers.
Shell completions¶
The .deb, .rpm, .apk and .pkg.tar.zst packages install
Bash,
Zsh and fish completions for you.
For a brew, scoop,
go-install or source build,
iq completion <shell> prints a script to install by hand.
Completions cover the commands, their sub-subcommands and flags. They also cover
the saved source handles, groups, and config-option keys, which they read live
from your config. As a result, iq --src <TAB> offers the sources iq ls lists.
A flag that takes a closed
set offers that option's own values.
iq inspect --only <TAB> and iq diff --section <TAB> offer the
introspection subcommands of the selected source's backend, worked out from its
saved URI.
The jq filter itself is a program, not a completable value. As a result, iq
offers no candidates there (and never falls back to filenames). iq also offers
no candidates for the backend verb of iq exec and its operands.
Every completion is offline. It reads your config file and nothing else. As a
result, a <TAB> never opens a connection, never reads the OS
keyring7, and cannot hang. That is why a collection suffix does not
complete. iq --src shop.<TAB> offers nothing, because listing collections
needs a connection.
Man page¶
The .deb, .rpm, .apk, and .pkg.tar.zst packages also install an iq(1) manual page, so man iq works
after a package install. For any other install, pipe it into your man path:
-
jqis a widely-used command-line utility and very high-level, functional, domain-specific programming language designed for processing JSON data. https://jqlang.org ↩ -
RFC3986 proposes a generic URI syntax and a process for resolving URI references that might be in relative form, along with guidelines and security considerations for the use of URIs on the Internet. https://datatracker.ietf.org/doc/html/rfc3986 ↩
-
Cgo enables the creation of Go packages that call C code. https://pkg.go.dev/cmd/cgo ↩
-
SHA-256 is a Secure Hash Algorithm with a message digest size of 256. https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.180-4.pdf ↩
-
An abstract syntax tree is the tree that a parser builds from the source of a program. Here, it is the parsed
jqfilter that the key selector inspects to decide how to read (see How it works). https://en.wikipedia.org/wiki/Abstract_syntax_tree ↩ -
Predicate pushdown hands part of the filter to the database, so that the database returns only matching items instead of everything for client-side filtering. Each driver page lists what the driver can push (see Drivers). https://en.wikipedia.org/wiki/Predicate_pushdown ↩
-
The operating system's credential store (macOS Keychain, Windows Credential Manager, the Secret Service on Linux), where
--store keyringsources keep their secrets (see Configuration). https://pkg.go.dev/github.com/zalando/go-keyring ↩