I want to do exactly what cursor.mogrify
does, but in a production appropriate way.
I'm updating some legacy Python code that builds queries by concatenating strings. I need to change this to escape safely.
The queries are long and built on a different server than they are run, so the normal process of using cursor.execute
to escape is unattractive for both code clarity and practical viability reasons.
I would use mogrify, but I understand that it is intended for debugging purposes only.
I've looked around and can't seem to find a good answer to this. What do you suggest?