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