The wrong reason is to add the same primary key, I think for a while, I grabbed the data primary key is ISBN ah, it is impossible to heavy ah, so, I went to the database to check the following error ISBN, inserted data also have, because the classification is not the same, so to insert again, this will definitely error, One way to deal with this is to
If you have this record in your database, you can skip this record and change the category of the book in the database to both categories while skipping this record.
Ans = Con.execute ("select * from B where isbn= (%s)", ISBN)
if (ans): Continue
Con.execute ("INSERT Into B (ISBN, BN, BK, BS, author, publisher, Publishdate) values (%s,%s,%s,%s,%s,%s,%s)", ([ISBN, BN, BK, BS, author, publisher, Publishdate]))
So the problem is solved.
When importing a text file into a database using Python, error: Duplicate entry ' ... ' for key ' PRIMARY '