title: How to set int column data to null with psycopg2
body: <p>I have this code and I'm trying to update a data row value to Null to test that it can be reselected on the front-end with Selenium Webdriver. It works fine when I run the sql manually against the data base but when I try to parameter substitute Null for an int column I get</p>
  
  <p>Here is the meaningful part of the stack</p>
  
  <pre><code>cursor.execute(query, (REASONS_CREATED[reason_created], order_id))
  DataError: invalid input syntax for integer: "Null"
  LINE 4:     reason_created_id = E'Null'
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>def update_reason_created_on_order(order_id, reason_created, environment='test'):
      '''
      Updates an order's reason created.
      '''
      sql_directory = find_path_to_sql_directory()
      with open(os.path.join(sql_directory, 'update_reason_created_on_order')) as sql:
          cursor = setup_database_cursor(environment)
          query = sql.read()
          try:
              cursor.execute(query, (REASONS_CREATED[reason_created], order_id))
          except:
              raise
  </code></pre>
  
  <p>Here is my Null entry for my REASONS_CREATED dictionary lookup</p>
  
  <pre><code>REASONS_CREATED = {'NULL': 'Null'}
  </code></pre>
  
  <p>Here is my sql in an external file</p>
  
  <pre><code>UPDATE
      order
  SET
      reason_created_id = %s
  WHERE
      order_id = %s;
  COMMIT;
  </code></pre>
  
  <p>I understand that psycopg2 does automatic type conversion and recognizes this reason_created_id is type int. Does anyone know how to set it to null? Also, the column is nullable.</p>