Skip to main content

escape_python_triple_double

Function escape_python_triple_double 

Source
pub fn escape_python_triple_double(sql: &str) -> String
Expand description

Escape SQL text for splicing into a Python triple-double-quoted """...""" string literal.

Triple-quoted strings permit raw newlines and tabs, so only backslash and " need escaping; escaping every " (not just runs of three) also means a lone or doubled quote can never accidentally combine with the literal’s own delimiter. Used by python-asyncpg, python-psycopg3, python-aiosqlite, python-aiomysql, python-duckdb, and (via python_common::write_execute_call) python-oracledb, python-snowflake, and python-pyodbc.