0

I am using mysql.connector library to connect to the MySQL database. Whenever I loop through my dictionary and add data to the database, I get the following error after a few successful insertions of records into the database.

Mysql error screenshot

Is it the right way to way to loop and add data to the database?

Asad
  • 1
  • 1
  • Please share more details, like the code involved and the error message, both in text form – Nico Haase Feb 02 '21 at 15:40
  • You may want to check this post here: https://stackoverflow.com/a/41836612/7510829 – radeveloper Feb 02 '21 at 19:20
  • @NicoHaase `import mysql.connector conn = mysql.connector.connect(host="localhost", user="root", passwd="", database="dbtest") cursor = conn.cursor() for kwl, count_of_proj in myDict: cursor.execute("INSERT INTO dbtest(kw,count) VALUES(%s, %s)", (kwl,count_of_proj)) conn.commit() conn.close()` – Asad Feb 03 '21 at 11:31
  • Please add all clarification to your question by editing it. This should also contain the error message – Nico Haase Feb 03 '21 at 12:40

0 Answers0