On Sun, Feb 09, 2014 at 12:03:43PM +0530, Sivaram Neelakantan wrote: > try: > sql = "insert into %s (%s) values(%s)" %(name, cl, cvv) > conn.executemany(sql, to_db) > dbh.commit() > except sq.IntegrityError: > print('Record already exists') # but which record??? > dbh.rollback()
When you get an error, and don't know how to interpret it, the first thing to do is to look at the exception and see what it says. try: # as above except sq.IntegrityError as exception: print(exception) dbh.rollback() Often (although not always) the exception will give you details on what went wrong. That should always be the first thing to look at. -- Steven _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor