title: Is it possible to catch a foreign key violation in postgres
body: <p>I'm trying to insert data into a table which has a foreign key constraint. If there is a constraint violation in a row that I'm inserting, I want to chuck that data away. </p>
  
  <p>The issue is that postgres returns an error every time I violate the constraint. Is it possible for me to have some statement in my insert statement like 'ON FOREIGN KEY CONSTRAINT DO NOTHING'?</p>
  
  <p>EDIT: </p>
  
  <p>This is the query that I'm trying to do, where info is a dict: </p>
  
  <pre><code>cursor.execute("INSERT INTO event (case_number_id, date, \
  session, location, event_type, worker, result) VALUES \
  (%(id_number)s, %(date)s, %(session)s, \
  %(location)s, %(event_type)s, %(worker)s, %(result)s) ON CONFLICT DO NOTHING", info)
  </code></pre>
  
  <p>It errors out when there is a foreign key violation</p>