title: How can I know which fiels cause IntegrityError when inserting into a table with multiple unique fields?
body: <p>I have a table with multiple unique fields in PostgreSQL. e.g.:</p>
  
  <pre><code>CREATE TABLE User (
      username VARCHAR,
      email    VARCHAR,
      UNIQUE (username),
      UNIQUE (email),
  )
  </code></pre>
  
  <p>When I insert into this table using SQLAlchemy, <code>IntegrityError</code> may occur. I can catch the exception, but it seems that the exception object doesn't have an attribute or something indicating which field is causing the error.</p>
  
  <p>How can I know which field violates the uniqueness constrain? I know parsing the exception message will work but is there a more elegent way to do this?</p>