How do I check if an insert was successful with MySQLdb in Python?
问题 I have this code: cursor = conn.cursor() cursor.execute(("insert into new_files (videos_id, filename, " "is_processing) values (%s,%s,1)"), (id, filename)) logging.warn("%d", cursor.rowcount) if (cursor.rowcount == 1): logging.info("inserted values %d, %s", id, filename) else: logging.warn("failed to insert values %d, %s", id, filename) cursor.close() Fun as it is, cursor.rowcount is always one, even though i updated my database to make the videos_id a unique key. That is, the insert fails