I am trying to update the values in the mysql database using parameterized queries. But after running the below code:
df = pd.read_sql('SELECT * FROM df LIMIT 3', con=db_connection)
print(df.shape)
labels = ('I1','I2','I3')
ids = (123456,123457,123458)
data = (labels,ids)
cursor = db_connection.cursor()
for i in df.id:
cursor.execute("UPDATE df SET label = %s WHERE id= %d",data)
db_connection.commit()
db_connection.close()
I am getting this error: TypeError: %d format: a number is required, not str
The data type of 'id' is int in database. And I am providing numbers only. don't know why it is throwing such error...