lundi 4 juillet 2016

TypeError: not all arguments converted during string formatting. What am I not doing right


I have tried:

sql = "INSERT INTO "+ tablenane + " ("+ ",".join(headers) +") VALUES (" + ",".join(["%s"] * len(headers)) + ")"

and:

sql = "INSERT INTO "+ tablenane + " ("+ ",".join(headers) +") VALUES (" + ",".join(["?"] * len(headers)) + ")"

but still get the same error when I run cursor.executemany(sql, dataset)

dataset = [(a,b,c),(d,e,f)] - A list of tuples

Both columns and values are dynamic, because there 40 columns. All table columns are of type VARCHAR and I ensure the data is converted to string before insertion

Using python 2.7 and mysql


Aucun commentaire:

Enregistrer un commentaire