The Python MySQL.connector keeps giving me the error Not all parameters used in the SQL statement. This is my code:
import mysql.connector
con = mysql.connector.Connect(user='root', password='password', database='DB', host='localhost')
cur = con.cursor()
#data inserter
add_data = "INSERT INTO DB.verkiezing (jaar, kamer, opkomst1, opkomst2, thema, gemeente, provincie, winnaar, VVD, PvdA, PVV, SP, CDA, D66, ChristenUnie, GROENLINKS, SGP, PvdD, 50Plus, OndernemersPartij, VNL, Denk, NieuweWegen, FvD) VALUES ($s, $s, $s, $s, $s, $s, $s, $s, $s, $s, $s, $s, $s, $s, $s, $s, $s, $s, $s, $s, $s, $s, $s, $s)"
#data
testvar = ('2017', "'Tweede", '81.9', '85.8', 'Identiteit', "'s-Gravenhage", 'Zuid-Holland', 'VVD', '33.0', '9.0', '20.0', '14.0', '19.0', '19.0', '5.0', '14.0', '3.0', '5.0', '4.0', '0.0', '0.0', '0.0', '0.0', '3.0')
cur.execute(add_data, testvar)
con.commit()
cur.close()
con.close()
The error pops up even though the number of %s and the number of columns match. If I try to do the same operation in MySQL itself, like so:
USE DB;
INSERT VALUES INTO verkiezing (jaar, kamer, opkomst1, opkomst2, thema, gemeente, provincie, winnaar, VVD, PvdA, PVV, SP, CDA, D66, ChristenUnie, GROENLINKS, SGP, PvdD, 50Plus, OndernemersPartij, VNL, Denk, NieuweWegen, FvD) VALUES ('2017', "Tweede", '81.9', '85.8', 'Identiteit', "'s-Gravenhage", 'Zuid-Holland', 'VVD', '33.0', '9.0', '20.0', '14.0', '19.0', '19.0', '5.0', '14.0', '3.0', '5.0', '4.0', '0.0', '0.0', '0.0', '0.0', '3.0');
It works, no problem. What am I doing wrong in Python? I use Python 3.6.1 and MySQL 14.14 Distrb 5.7.14. Thank you in advance