coolqlite.query¶
Query processing.
You probably won’t need to use this module
if you’re just using coolqlite.Connection.query(),
but it may be handy if you want to debug your queries or conversions.
Query proccessing happens in two steps, arbitrarily (but alphabetically!) named “analyze” and “build”.
Analyze takes a
string.templatelib.Template(t-string) and turns it into anAnalyzedQuery, which holds the sql query string and named parameters. The values of those parameters haven’t been converted yet though.Build takes that
AnalyzedQueryand turns it into aBuiltQuery, which has run all conversions. This step can fail, but it will collect all errors into aCoolqliteExceptionGroupso you can see each one.
Warning
These names will likely change, especially if we eventually get an actual query builder.
These mostly exist for you to debug your queries and conversions; it should not be a stable API to depend upon for now.
- coolqlite.query.analyze_query(query: Template) AnalyzedQuery¶
Anlyze a template.
- class coolqlite.query.AnalyzedQuery(query_str: str, params: dict[str, Param])¶
Bases:
objectA template that has been analyzed into the query string and (possibly name-mangled) parameters, ready to be converted.
- class coolqlite.query.Param(*, param_name: str, original_param_expr: str, converter_name: str, original_value: Any)¶
Bases:
objectAn analyzed input parameter.
- param_name: str¶
The name assigned to the parameter.
May be mangled if a filter was applied or it wasn’t a valid identifier.
- class coolqlite.query.ConvertedParam(*, param_name: str, original_param_expr: str, converter_name: str, original_value: Any, converted_value: Any)¶
Bases:
ParamA param that has been converted.
- class coolqlite.query.BuiltQuery(query_str: str, params: dict[str, ConvertedParam])¶
Bases:
objectA query that has been “built” from an
AnalyzedQuery, with its parameters converted.- params: dict[str, ConvertedParam]¶
Maps (possibly mangled) param name to the param.
- exception coolqlite.query.ParamMissingToSqlFnError(param: Param, cause: MissingToSqlFnError)¶
Bases:
CoolqliteErrorA converter fn was missing. See error message for details.
- cause: MissingToSqlFnError¶
This should be the same as
__cause__but this helps guarantee it’s there.
- exception coolqlite.query.ToSqlFnFailure(param: Param)¶
Bases:
CoolqliteErrorA converter itself threw an exception.
- exception coolqlite.query.QueryBuilderErrorGroup(message, exceptions, *_args, **kwargs)¶
Bases:
CoolqliteExceptionGroup[ParamMissingToSqlFnError|ToSqlFnFailure]Errors that occurred during query building.