ds_common_placeholder_py_lib.sql ================================ .. py:module:: ds_common_placeholder_py_lib.sql .. autoapi-nested-parse:: **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 --------- .. autoapisummary:: ds_common_placeholder_py_lib.sql.refuse_secrets_in_sql ds_common_placeholder_py_lib.sql.sql_errors ds_common_placeholder_py_lib.sql.literal ds_common_placeholder_py_lib.sql.position_errors Module Contents --------------- .. py:function:: refuse_secrets_in_sql(sql: str, path: str) -> list[ds_common_placeholder_py_lib.grammar.Segment] Check the SQL text at *path* before anything is read. :returns: ``parse(sql)``. :raises PlaceholderError: ``syntax``, ``sql_position``, or ``sql_secret`` for a ``get_secret`` or ``secret`` call at any depth, with *path*. .. py:function:: sql_errors(sql: str) -> list[ds_common_placeholder_py_lib.errors.PlaceholderError] Every error of the SQL text that its text alone shows, for :func:`~ds_common_placeholder_py_lib.validate.validate`: ``sql_position`` for each misplaced placeholder, ``sql_secret`` for each one with a ``get_secret`` or ``secret`` call at any depth. :raises PlaceholderError: ``syntax``, if *sql* does not parse. .. py:function:: literal(value: Any, placeholder: ds_common_placeholder_py_lib.grammar.Placeholder) -> str Render a JSON value as a SQL literal. :raises PlaceholderError: ``type`` for anything but a string, number, or boolean. .. py:function:: position_errors(sql: str, segments: list[ds_common_placeholder_py_lib.grammar.Segment]) -> list[ds_common_placeholder_py_lib.errors.PlaceholderError] Find placeholders inside quotes or comments, or glued to other tokens. :param sql: The statement. :param segments: ``parse(sql)``. :returns: One ``sql_position`` error per misplaced placeholder.