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

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

quarb-0.1.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.1.0.tar.gz.

File metadata

  • Download URL: quarb-0.1.0.tar.gz
  • Upload date:
  • Size: 252.6 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.0.tar.gz
Algorithm Hash digest
SHA256 c60ccee4842cc1446736701cd413c088a79c796078c8b2c478139d63dddca1fc
MD5 7a5ce3e5b2d50544ddede59ad6d8a29a
BLAKE2b-256 7c79467d994ca25cd31c3321f03e5684c08243256b8c82d2aeb070bac094d9d9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: quarb-0.1.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.1.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c5c7b4d381c900495fec9c35364ef01d7a24d440f48d5514942dee17fe3f0d2b
MD5 133ff5c93fe0ee59a51081d6739db7ac
BLAKE2b-256 c694a8aee87f95aac26b78f9803a19a98b78271cfc97897889940dcbf73006ab

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for quarb-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0239510bf4ec7a0f667aeceec99ff3445b0f961ba81db1bf564dc611e7cd2624
MD5 4a06769260e74a6d22f76d480592a7da
BLAKE2b-256 e687a4ff4db79926a2452f5ac51968c51fe95e632890a29adb089580dde8716e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for quarb-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 97166ce2de1d902d6c63d4eb33d7d1220c87e712d556914bb1899bb1ccc76469
MD5 82b7e960cdaae67b83ac06cd49f2fa13
BLAKE2b-256 e935af3f8db2896f764dbe94793a7c9eb08759db6a0dd7f38fda121299fec8a4

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: quarb-0.1.0-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.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 07ccb95f46d916fe8289b66634bd11ef72f693f32d32b8749c2efc5f2ab1666b
MD5 3c105f1deb6ca507b71bd49617b1014d
BLAKE2b-256 c167fdb964cbacef3d7fcf863a88d59f6f5898d9d437347fb5634c48c7d858ef

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for quarb-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ff039a29ac365edbffc0299a5b58fcbe0c675fd98f4cac031374b43198f4ceee
MD5 e134782c0c372bdf86763b318f7c7451
BLAKE2b-256 f3bada1e734f9304a6e59c3fb121dbae6ab4a8fa51ff8bd3be624f5909e0f9d7

See more details on using hashes here.

Provenance

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