title: How to quote a string value explicitly (Python DB API/Psycopg2)
body: <p>For some reasons, I would like to do an explicit quoting of a string value (becoming a part of constructed SQL query) instead of waiting for implicit quotation performed by <code>cursor.execute</code> method on contents of its second parameter.</p>
  
  <p>By "implicit quotation" I mean:</p>
  
  <pre><code>value = "Unsafe string"
  query = "SELECT * FROM some_table WHERE some_char_field = %s;"
  cursor.execute( query, (value,) ) # value will be correctly quoted
  </code></pre>
  
  <p>I would prefer something like that:</p>
  
  <pre><code>value = "Unsafe string"
  query = "SELECT * FROM some_table WHERE some_char_field = %s;" % \
      READY_TO_USE_QUOTING_FUNCTION(value)
  cursor.execute( query ) # value will be correctly quoted, too
  </code></pre>
  
  <p>Is such low level <code>READY_TO_USE_QUOTING_FUNCTION</code> expected by Python DB API specification (I couldn't find such functionality in <a href="http://www.python.org/dev/peps/pep-0249/" rel="noreferrer">PEP 249</a> document). If not, maybe Psycopg2 provides such function? If not, maybe Django provides such function? I would prefer not to write such function myself...</p>