Skip to content

cql2-rs

cql2-rs is Python package, command-line interface (CLI), and Rust crate for parsing, validating, and converting Common Query Language (CQL2).

Python

>>> from cql2 import Expr
>>> expr = Expr("landsat:scene_id = 'LC82030282019133LGN00'")
>>> expr.to_json()
{'op': '=', 'args': [{'property': 'landsat:scene_id'}, 'LC82030282019133LGN00']}

CLI

$ cql2 < tests/fixtures/text/example01.txt # will succeed if the CQL2 is valid
("landsat:scene_id" = 'LC82030282019133LGN00')

Rust

use cql2::Expr;
let expr: Expr = "landsat:scene_id = 'LC82030282019133LGN00'".parse();
let json = expr.to_json().unwrap();