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.1.1.tar.gz (254.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.1.1-cp38-abi3-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.8+Windows x86-64

quarb-0.1.1-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.1.1-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.1.1-cp38-abi3-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

quarb-0.1.1-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.1.1.tar.gz.

File metadata

  • Download URL: quarb-0.1.1.tar.gz
  • Upload date:
  • Size: 254.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.1.1.tar.gz
Algorithm Hash digest
SHA256 a7dc42ec29a1d7b71deef44ca521e2baff4fe9a5c1ff56dcfce9517fab74f6d0
MD5 5205bb9be72a4dc0bfb6693b9d7a845c
BLAKE2b-256 d9f46842bf6238f29d632c65243d776c1cf83c7654f69aaca52eacf148ec966c

See more details on using hashes here.

Provenance

The following attestation bundles were made for quarb-0.1.1.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.1.1-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: quarb-0.1.1-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.1.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9cacabef3f9ff24d5c663a40dbadf54fa85c2179f3ca8d75f496c09229e79ad7
MD5 f447448d618176b02838ad021d191610
BLAKE2b-256 1368733297b904efd2b95fc88024758911aa27ccab27c8caf47469f5d0110dfc

See more details on using hashes here.

Provenance

The following attestation bundles were made for quarb-0.1.1-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.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quarb-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fe8a2cf13f0233055dc276e688dbd26f732741dbaa7b8be517235f5f5e41e129
MD5 e7a7a74d3152d38d514a638160c29568
BLAKE2b-256 4d9ecaaefb56e11fee093c22ae9bea6cbb4ec9124e8e0ecad6e373114002726b

See more details on using hashes here.

Provenance

The following attestation bundles were made for quarb-0.1.1-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.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for quarb-0.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 36754e48c06a146d668096f00091beb9412405a8b7246ef7ddd7ecfd5f25eb13
MD5 d87f67e3e0174776f4c794db206f3c3b
BLAKE2b-256 c6823b48e3f62212a12fc7ccbf141b0a6208fc6b0c2fc61d47c9d90f5b67a13f

See more details on using hashes here.

Provenance

The following attestation bundles were made for quarb-0.1.1-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.1.1-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: quarb-0.1.1-cp38-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.3 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.1.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fe461c5158debc9cb31ec8b7157f159aadc8f4778a3de43c40f28333c1e8cfce
MD5 c373b715c3cbfd1b1b313862415fb75a
BLAKE2b-256 6b9cb68e7f4d002ba055eb00cba7f64bc170cc8126ff9c469a86adbd7f44e441

See more details on using hashes here.

Provenance

The following attestation bundles were made for quarb-0.1.1-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.1.1-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for quarb-0.1.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 38e963660364f5313584a959e17bbeac7e6d21436fc48688aecdc0eafa36db52
MD5 2e0856ca3cc98011ee37c3e645b338bc
BLAKE2b-256 9b62d1583ad69a5450134c93d5ff97c84a4837f50720c852b0c4b1f0ae92a175

See more details on using hashes here.

Provenance

The following attestation bundles were made for quarb-0.1.1-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