Skip to content Skip to sidebar Skip to footer

There Is An TypeError: Execute() Takes At Most 3 Arguments (6 Given) When Inserting Into Mysql Table

I have made a webscraper in python and I am now trying to get it to output the data i have scraped into a mysqldb but I keep getting this error and I don't know how to fix it.this

Solution 1:

You need to pass the values in as a tuple

cursor.execute("INSERT INTO london10dayforecast (Day,Condition,High,Low) VALUES (%s,%s,%s,%s)", (str(var1),str(var2),str(var3),str(var4)))

or more readably

qstr = "INSERT INTO london10dayforecast (Day,Condition,High,Low) VALUES (%s,%s,%s,%s)"
params = str(var1), str(var2), str(var3), str(var4)
cursor.execute(qstr, params)

Post a Comment for "There Is An TypeError: Execute() Takes At Most 3 Arguments (6 Given) When Inserting Into Mysql Table"