ds_common_placeholder_py_lib.sql¶
File: sql.py
Region: ds-common-placeholder-py-lib
Description¶
Placeholders in SQL text become SQL literals, never raw text (contract §8.3).
The lexer knows DuckDB’s quoting: '…', E'…', "…", $tag$…$tag$,
-- and nested /* */ comments.
Functions¶
|
Check the SQL text at path before anything is read. |
|
Every error of the SQL text that its text alone shows, for |
|
Render a JSON value as a SQL literal. |
|
Find placeholders inside quotes or comments, or glued to other tokens. |
Module Contents¶
- ds_common_placeholder_py_lib.sql.refuse_secrets_in_sql(sql: str, path: str) list[ds_common_placeholder_py_lib.grammar.Segment][source]¶
Check the SQL text at path before anything is read.
- Returns:
parse(sql).- Raises:
PlaceholderError –
syntax,sql_position, orsql_secretfor aget_secretorsecretcall at any depth, with path.
- ds_common_placeholder_py_lib.sql.sql_errors(sql: str) list[ds_common_placeholder_py_lib.errors.PlaceholderError][source]¶
Every error of the SQL text that its text alone shows, for
validate():sql_positionfor each misplaced placeholder,sql_secretfor each one with aget_secretorsecretcall at any depth.- Raises:
PlaceholderError –
syntax, if sql does not parse.
- ds_common_placeholder_py_lib.sql.literal(value: Any, placeholder: ds_common_placeholder_py_lib.grammar.Placeholder) str[source]¶
Render a JSON value as a SQL literal.
- Raises:
PlaceholderError –
typefor anything but a string, number, or boolean.
- ds_common_placeholder_py_lib.sql.position_errors(sql: str, segments: list[ds_common_placeholder_py_lib.grammar.Segment]) list[ds_common_placeholder_py_lib.errors.PlaceholderError][source]¶
Find placeholders inside quotes or comments, or glued to other tokens.
- Parameters:
sql – The statement.
segments –
parse(sql).
- Returns:
One
sql_positionerror per misplaced placeholder.