for row in dfp.itertuples():
cursor.execute('''
INSERT INTO athletes(id, season, name)
VALUES (?,?,?)
''',
(
row.id,
row.season,
row.name,
)
'''
)
mysql.connector.errors.ProgrammingError: Not all parameters were used in the SQL statement.
I am getting this error because name is composed of first name and last name, so it is considering it as two different parameters when in reality it is only a single parameter. The same thing is happening in another table when I am using date (considering it as 3 parameters).
CodePudding user response:
In pymysql, don't use ?
as the parameter placeholders. Use %s
.
cursor.execute('''INSERT INTO athletes(id, season, name) VALUES (%s,%s,%s)''',
(row.id, row.season, row.name,))