 <p>I normally use a try catch for this.</p> <pre><code>try: session.commit() catch: str(sys.exc_info()[0]) + " \nDESCRIPTION: "+ str(sys.exc_info()[1]) + "\n" + str(sys.exc_info()[2]) </code></pre> <p>When I encounter an integrity error, I get the following message and I skip that particular transcation and continue with the rest of them</p> <pre><code>DESCRIPTION: (IntegrityError) duplicate key value violates unique constraint "test_code" DETAIL: Key (test_code)=(5342) already exists. 'INSERT INTO test_table (pk, test_code, test_name) VALUES (%(pk)s, %(test_code)s, %(test_name)s)' { 'pk': '1', 'test_code': '5342', 'test_name': 'test' } </code></pre>