Skip to main content

Structure-aware queries over JSON, YAML, TOML, CSV, XML, HTML, and Markdown — Python bindings for the Quarb query engine

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::'

The full qua CLI — file systems, git, databases, mail, adapter composition — is 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quarb-0.2.0.tar.gz (258.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

quarb-0.2.0-cp38-abi3-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.8+Windows x86-64

quarb-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

quarb-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

quarb-0.2.0-cp38-abi3-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

quarb-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file quarb-0.2.0.tar.gz.

File metadata

  • Download URL: quarb-0.2.0.tar.gz
  • Upload date:
  • Size: 258.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for quarb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ae439ca4995e0fdee386c4918cf4a3b04e419125ff50b92cfee223680759b945
MD5 5f6b3636c4901d42348e2579b94d894a
BLAKE2b-256 dd2b530e1c21b6b3631ad458ecf3bf12e332a87aebd745ab26d1d348ef06433d

See more details on using hashes here.

Provenance

The following attestation bundles were made for quarb-0.2.0.tar.gz:

Publisher: publish-pypi.yml on deyanovich/quarb-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quarb-0.2.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: quarb-0.2.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.5 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

Hashes for quarb-0.2.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 242e4bbdf3de0d0b4dede7038f07e0b638c44c6590b81b350c8bfe703c2e08ac
MD5 b22d71de577014d513e4fbfc525fa496
BLAKE2b-256 73301b9bec8111fbf5cca682bea4b8a333739234a48cc81022baa51ff5546063

See more details on using hashes here.

Provenance

The following attestation bundles were made for quarb-0.2.0-cp38-abi3-win_amd64.whl:

Publisher: publish-pypi.yml on deyanovich/quarb-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quarb-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quarb-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 74b569655e9d93f07788776304b504d41c4a55e27cc4e586c8766e3c26f32ec4
MD5 34a0941d95fd9df6ac56e146eea27bba
BLAKE2b-256 a384791a3b7eabefc182c4a73e581c87a92e698b0b58f6881a5173c547e849ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for quarb-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pypi.yml on deyanovich/quarb-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quarb-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for quarb-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 01b4a53ae92c315245ea02874821f0284c9d2a66ea326e03a8ef5971e6cec41d
MD5 b720f0003cfd491c1b9175080eeee939
BLAKE2b-256 954e62549019d2f33b9780c69b7f9680b7fac94519716948cf6c419122b49e59

See more details on using hashes here.

Provenance

The following attestation bundles were made for quarb-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-pypi.yml on deyanovich/quarb-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quarb-0.2.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: quarb-0.2.0-cp38-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.4 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

Hashes for quarb-0.2.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 42e2d975ab6d056ba8eb8b3a170d4d3a9426945f9a81e2d7e1ef6274c9e66d3a
MD5 d90c2100a2791b1b4625b78da0e11df7
BLAKE2b-256 907be80cbcf1cf757d79817d1b296df1f9095f61d50cb882db1636065b7fa6ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for quarb-0.2.0-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: publish-pypi.yml on deyanovich/quarb-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quarb-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for quarb-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6bed406f6b121e93080480b19deaa443e9090c44979ef069ce8ab3613c62cab9
MD5 8e07dceb4b8f2dd4717958e646e6fbb5
BLAKE2b-256 a77dcc82a7e92af4346f99fce23416a9cc866ca3ca7fee50a7cb3a5a2f6ed735

See more details on using hashes here.

Provenance

The following attestation bundles were made for quarb-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: publish-pypi.yml on deyanovich/quarb-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page