I'm trying to insert records to my db from an array :
for string in self.FinalMailsArray:
c.execute("""INSERT INTO table (email) VALUES(%s) """,(string))
The problem is, that I want the field email to be unique, so I enabled that in the DB. When I start inserting, I get errors for duplicate entry value.
Is there a way where I can say, "if there is a duplicate error thrown, just go to the next string in the array" ?
INSERT IGNORE will ignore inserts that would otherwise conflict with a unique key:
for string in self.FinalMailsArray:
c.execute("""INSERT IGNORE INTO table (email) VALUES(%s) """,(string))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With