Parse, validate, and convert Common Query Language (CQL2) text and JSON
Actively maintained. Last release 4 weeks ago, commits in 20 of the last 26 weeks. A safe choice.
pip install cql2cql2
Python library and command-line interface (CLI) for parsing and converting Common Query Language (CQL2), with Rust under the hood.
Usage
pip install cql2
Then:
from cql2 import Expr, parse_file
expr = Expr("landsat:scene_id = 'LC82030282019133LGN00'")
# or
expr = parse_file("examples/text/example01.txt")
s = expr.to_text()
d = expr.to_json()
sql = expr.to_sql()
print("cql2-text:", s)
print("cql2-json:", d)
print("SQL:", sql)
Or from via the command-line interface:
$ cql2 -o json "landsat:scene_id = 'LC82030282019133LGN00'"
{"op":"=","args":[{"property":"landsat:scene_id"},"LC82030282019133LGN00"]}
Developing
To install the package to your virtual environment and test:
maturin develop --uv -m python/Cargo.toml && pytest python
More information
This package is part of cql2-rs, see that repo for license and contributing information.