Query utils
Imports¶
Python modules
import json
from textwrap import dedent
from typing import Any, UnionConstants¶
NULL_CURSOR¶
A strict JSON string serialization representing a null or absent cursor marker, preventing malformed dictionary conversions during iterative queries.
NULL_CURSOR: str = json.dumps(None)Functions¶
build_query¶
Helper function for rendering safe strings. Constructs a formatted query string by interpolating the specified parameter dictionary into the designated template.
def build_query(template: str, *, params: dict[str, Any] | None = None) -> str:
"""Render a query payload using templates and parameters.
Args:
template: The baseline template text.
params: The configuration values to combine into the template representation.
Defaults to None.
Returns:
The completed query string parameter definitions.
"""
if not params:
params = {}
return dedent(template.strip()) % params