title: pyscopg2 select NULL values
body: <p>How do I use <a href="http://initd.org/psycopg/docs/usage.html#passing-parameters-to-sql-queries" rel="noreferrer">string substitution</a> in Psycopg2 to handle both NULL and non-NULL values?</p>
  
  <p>For example:</p>
  
  <pre><code>sql = 'SELECT * FROM table WHERE col = %s;'
  possible_params = [1, None]
  
  for x in possible_params:
      print cur.mogrify(sql,(x,))
  </code></pre>
  
  <p>I need the first query to look like <code>SELECT * FROM table WHERE col = 1;</code> And the second to be the functional equivalent of <code>SELECT * FROM table WHERE col IS NULL;</code></p>
  
  <p>Is there a trick? I have many columns that may be NULL or have a value so building the SQL dynamically is fairly cumbersome.</p>