goal
output \"
in python.
problems
Suppose we want to generate SQL in python to insert data into a table with json format columns (we'll feed it to the RDBMS later).
When you generate a json string in python, the double quotation is converted to \\"
. However, in the json format, escaped double quotation is represented as \"
. As it is, SQL generated in python cannot be directly applied to an RDBMS.
But, in python, single back slash (\
) is expressed by \\
, and escaped double quotation (\"
) is expressed by \\"
. If create string object like \"
, python will interpret it as "
.
What do you think is the best way to output \"
in python?