One query language for every tree — Python bindings for the Quarb engine: JSON, YAML, TOML, CSV, XML, HTML, Markdown, SQLite, kaiv (typed units), filesystem, git, archives, XLSX, and source code (Rust/Python/JS/C), plus jq/XPath/SQL translators
Project description
qua
Python bindings for the Quarb query engine. Quarb reads structured text as an arbor — a tree-spanned graph — and runs one query language over all of it, generalizing what XPath does for XML and jq does for JSON to JSON, YAML, TOML, CSV/TSV, XML, HTML, and Markdown alike. Try it live in the playground.
Install
pip install quarb
This installs the quarb Python module and the qua command
(the language is Quarb; qua is its CLI).
Wheels are published for Linux (x86_64, aarch64), macOS (arm64,
x86_64), and Windows (x86_64). The extension is built against
PyO3's stable ABI (abi3-py38); a single wheel covers CPython
3.8 and later.
The qua command
The entry point covers what the bindings cover — one query over a text document:
qua '/books/*[/price:: > 20]/title::' store.json
echo '{"users":[{"name":"ada"}]}' | qua -f json '/users/*/name::'
Beyond text, quarb.open(path) dispatches on kind over the full
local fleet — SQLite, kaiv (typed units), the filesystem
(descend=True grafts parseable leaves), git (git:PATH),
archives, XLSX, and source code — and quarb.mount([a, b, ...])
mounts several sources under one root so a single query joins
across them (a YAML file <=> a SQLite database). The networked
adapters — Postgres, MySQL, BigQuery, Neo4j, object stores,
mail — and DuckDB live in the Rust binary: cargo install qua.
Quick start
import quarb
doc = quarb.loads("""{
"books": [
{"title": "Sapiens", "price": 25},
{"title": "Cosmos", "price": 18}
]
}""", "json")
doc.values('/books/*[/price:: > 20]/title::')
# ['Sapiens']
doc.value('/books/*/price:: @| mean')
# 21.5
doc.records('/books/* | rec("t", /title::, "p", /price::)')
# [{'t': 'Sapiens', 'p': 25}, {'t': 'Cosmos', 'p': 18}]
loads(text, format) / load(path) parse once into a
Document, queried many times. Results come back typed:
ints, floats, strings, None for null, tz-aware datetime for
instants, timedelta for durations, Quantity for unit-carrying
values, dicts for records. Formats: json, yaml, toml,
csv, tsv, xml, html, markdown.
The lower-level quarb.run(query, text, format) and
quarb.run_file(query, path) return the result lines as
strings — exactly what the qua CLI prints. All errors raise
ValueError with the engine's message.
For the query language itself — steps, criteria, readings, patterns, joins — see the user guide and spec.
License
Licensed under either of Apache License, Version 2.0 or the MIT license at your option. Both texts are bundled in the package.
Jupyter
%load_ext quarb.ipython
%quarb_mount fleet.daiv
%quarb /@hosts/*[::power > 0.2kW]::name
%%quarb [NAME] runs a cell-sized query against a named mount;
results render as HTML tables, iterate as typed values
(quantities keep magnitude + unit), and convert with .df /
.df_magnitudes().
For a notebook where every cell is a query, install the dedicated kernel and pick Quarb in the launcher:
python -m quarb.kernel install
python -m quarb.kernel demo # writes quarb-demo.ipynb to try
Cells are queries; %mount, %connect, %use, %docs,
%translate, and %python (an escape hatch — the rest of the
cell is Python, with the live session and the last result _
in scope) are the directives. Tab-completion offers the mounted arbor's real child names,
and the bundled JupyterLab extension highlights Quarb syntax
in cells automatically. %connect NAME PATH... (magic:
%quarb_connect) attaches to a qua --resident daemon — for
arbors too large to rebuild per notebook, queried from a
standing session. pip install quarb[jupyter] pulls IPython,
pandas, and the kernel runtime.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quarb-0.3.4.tar.gz.
File metadata
- Download URL: quarb-0.3.4.tar.gz
- Upload date:
- Size: 493.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5e2128eafbf092dc8f10f95de89f285aae0da6e173623f60ce51721b9926a40
|
|
| MD5 |
54e7df3dff7653342db22f588589bce8
|
|
| BLAKE2b-256 |
8e66253854d1379f420c5f5445c4c8407c0cb46477b377e0111bf5fd49746a59
|
Provenance
The following attestation bundles were made for quarb-0.3.4.tar.gz:
Publisher:
publish-pypi.yml on deyanovich/quarb-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quarb-0.3.4.tar.gz -
Subject digest:
a5e2128eafbf092dc8f10f95de89f285aae0da6e173623f60ce51721b9926a40 - Sigstore transparency entry: 2200771436
- Sigstore integration time:
-
Permalink:
deyanovich/quarb-rs@42289cfcd9f8a5f6adfc4585355e08ac4f000fe4 -
Branch / Tag:
refs/tags/py/v0.3.4 - Owner: https://github.com/deyanovich
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@42289cfcd9f8a5f6adfc4585355e08ac4f000fe4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quarb-0.3.4-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: quarb-0.3.4-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 5.3 MB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c65c87ef4dadab81043f7e49e98d2e76eb263fe3fa80521cc00ac70f53114cf1
|
|
| MD5 |
68c077778726b33e1359caa093eb020f
|
|
| BLAKE2b-256 |
f75c86f88c4f9333e227704f01e7a47716abd48c520ee49160ae98a7d34347f8
|
Provenance
The following attestation bundles were made for quarb-0.3.4-cp38-abi3-win_amd64.whl:
Publisher:
publish-pypi.yml on deyanovich/quarb-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quarb-0.3.4-cp38-abi3-win_amd64.whl -
Subject digest:
c65c87ef4dadab81043f7e49e98d2e76eb263fe3fa80521cc00ac70f53114cf1 - Sigstore transparency entry: 2200771613
- Sigstore integration time:
-
Permalink:
deyanovich/quarb-rs@42289cfcd9f8a5f6adfc4585355e08ac4f000fe4 -
Branch / Tag:
refs/tags/py/v0.3.4 - Owner: https://github.com/deyanovich
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@42289cfcd9f8a5f6adfc4585355e08ac4f000fe4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quarb-0.3.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: quarb-0.3.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.4 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff3ce735f6a901a0175727a5bf1eaa80191988fb63deb5e247c62565e9464e17
|
|
| MD5 |
1c7aa4a06eecdec481d84ded6cd18dec
|
|
| BLAKE2b-256 |
7a660793e3c3a42a5f7f06aef291cc72ceb82c6264e21e0d30cb23f379a917f4
|
Provenance
The following attestation bundles were made for quarb-0.3.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish-pypi.yml on deyanovich/quarb-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quarb-0.3.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
ff3ce735f6a901a0175727a5bf1eaa80191988fb63deb5e247c62565e9464e17 - Sigstore transparency entry: 2200771507
- Sigstore integration time:
-
Permalink:
deyanovich/quarb-rs@42289cfcd9f8a5f6adfc4585355e08ac4f000fe4 -
Branch / Tag:
refs/tags/py/v0.3.4 - Owner: https://github.com/deyanovich
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@42289cfcd9f8a5f6adfc4585355e08ac4f000fe4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quarb-0.3.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: quarb-0.3.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.1 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76e452634a557b911f03b4eefc29e7542eda7437167da051d73f80ff1d9c3ae2
|
|
| MD5 |
dbd83f93cafce52f8c50385e8ebe4433
|
|
| BLAKE2b-256 |
3d2188367fbd443d39fa270e67961d3de82432df03d5aa01333cea9df90f87e4
|
Provenance
The following attestation bundles were made for quarb-0.3.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish-pypi.yml on deyanovich/quarb-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quarb-0.3.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
76e452634a557b911f03b4eefc29e7542eda7437167da051d73f80ff1d9c3ae2 - Sigstore transparency entry: 2200771558
- Sigstore integration time:
-
Permalink:
deyanovich/quarb-rs@42289cfcd9f8a5f6adfc4585355e08ac4f000fe4 -
Branch / Tag:
refs/tags/py/v0.3.4 - Owner: https://github.com/deyanovich
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@42289cfcd9f8a5f6adfc4585355e08ac4f000fe4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quarb-0.3.4-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: quarb-0.3.4-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.8 MB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
046ebea36d0a50a2dd9224775d8f96723b885a49883257fdf661110da032d9c0
|
|
| MD5 |
04045fe1b92360c49a91d87f04b5f1de
|
|
| BLAKE2b-256 |
fd0a9dfaeaab30c1739a3b314c48833d512d3db4afecbc9c987107ef716c5227
|
Provenance
The following attestation bundles were made for quarb-0.3.4-cp38-abi3-macosx_11_0_arm64.whl:
Publisher:
publish-pypi.yml on deyanovich/quarb-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quarb-0.3.4-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
046ebea36d0a50a2dd9224775d8f96723b885a49883257fdf661110da032d9c0 - Sigstore transparency entry: 2200771676
- Sigstore integration time:
-
Permalink:
deyanovich/quarb-rs@42289cfcd9f8a5f6adfc4585355e08ac4f000fe4 -
Branch / Tag:
refs/tags/py/v0.3.4 - Owner: https://github.com/deyanovich
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@42289cfcd9f8a5f6adfc4585355e08ac4f000fe4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quarb-0.3.4-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: quarb-0.3.4-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 5.1 MB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5c2f0d2ff193c1a6bac54e099f15a39a1e26c4d9f712f891d83f8fa06ef27dc
|
|
| MD5 |
861cc5f9443eb4da45bbe25995bcbc12
|
|
| BLAKE2b-256 |
2850cf383fca472ba96661788497a2c816f5180f5daf5ab5ffb57fa207e78a11
|
Provenance
The following attestation bundles were made for quarb-0.3.4-cp38-abi3-macosx_10_12_x86_64.whl:
Publisher:
publish-pypi.yml on deyanovich/quarb-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quarb-0.3.4-cp38-abi3-macosx_10_12_x86_64.whl -
Subject digest:
c5c2f0d2ff193c1a6bac54e099f15a39a1e26c4d9f712f891d83f8fa06ef27dc - Sigstore transparency entry: 2200771733
- Sigstore integration time:
-
Permalink:
deyanovich/quarb-rs@42289cfcd9f8a5f6adfc4585355e08ac4f000fe4 -
Branch / Tag:
refs/tags/py/v0.3.4 - Owner: https://github.com/deyanovich
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@42289cfcd9f8a5f6adfc4585355e08ac4f000fe4 -
Trigger Event:
push
-
Statement type: