Python
Python API documentation for the cql2 package. Install from PyPI:
API
cql2.parse_file(path)
Parses CQL2 from a filesystem path.
Parameters:
-
path
(PathLike | str
) –The input path
Returns:
-
Expr
(Expr
) –The CQL2 expression
Examples:
cql2.parse_json(s)
Parses cql2-json.
Parameters:
-
s
(str
) –The cql2-json string
Returns:
-
Expr
(Expr
) –The CQL2 expression
Raises:
-
ParseError
–Raised if the string does not parse as cql2-json
Examples:
cql2.parse_text(s)
Parses cql2-text.
Parameters:
-
s
(str
) –The cql2-text
Returns:
-
Expr
(Expr
) –The CQL2 expression
Raises:
-
ParseError
–Raised if the string does not parse as cql2-text
Examples:
cql2.Expr(cql2)
A CQL2 expression.
The cql2 can either be a cql2-text string, a cql2-json string, or a cql2-json dictionary.
Parameters:
-
cql2
(str | dict[str, Any]
) –The input CQL2
Examples:
>>> from cql2 import Expr
>>> expr = Expr("landsat:scene_id = 'LC82030282019133LGN00'")
>>> expr = Expr({"op":"=","args":[{"property":"landsat:scene_id"},"LC82030282019133LGN00"]})
to_json()
Converts this cql2 expression to a cql2-json dictionary.
Returns:
-
dict[str, Any]
–dict[str, Any]: The cql2-json
Examples:
to_sql()
Converts this cql2 expression to a SQL query.
Returns:
-
SqlQuery
(SqlQuery
) –The SQL query and parameters
Examples:
to_text()
validate()
Validates this expression using json-schema.
Raises:
-
ValidationError
–Raised if the validation fails
Examples:
cql2.SqlQuery
A SQL query
params: list[str]
instance-attribute
The parameters, to use for binding.
query: str
instance-attribute
The query, with parameterized fields.
cql2.ParseError
Bases: Exception
An error raised when cql2 parsing fails.
cql2.ValidationError
Bases: Exception
An error raised when cql2 json-schema validation fails.