I get row of datafram and insert to mysql with this code, res is data I want to insert to mysql.
res = df.loc[df.ID == l_id]
mycursor = mydb.cursor()
sql = "INSERT INTO log (id, user, number, state, j_id) VALUES (%s, %s, %s, %s, %s )"
val = [(None, res['User'], res['Pages'] , res['State'], l_id )]
mycursor.executemany(sql, val)
mydb.commit()
print(mycursor.rowcount, "was inserted.")
mycursor.close()
when I run it show error like this.
ProgrammingError: Failed processing format-parameters; Python 'series' cannot be converted to a MySQL type
How to add data from dataframe to MySQL?