try the below code
import mysql.connector
cnx = mysql.connector.connect(user='root', password='', host='127.0.0.1', database='DB')
cursor = cnx.cursor()
Name = "James"
Department = "Finance"
StartYear = 2001
CurrentPos = 2001
Link = ""
add_user = ("INSERT INTO DB.tbluser "
"(username, department, startyear, currentpos, link) "
"VALUES (%s, %s, %s, %s, %s)")
data_user = (Name, Department, StartYear, CurrentPos, Link)
cursor.execute(add_user, data_user)
cnx.commit()
cursor.close()
cnx.close()
Error message “ mysql.connector.errors” is caused by mismatch between placeholders in your sql statement and data types in “data_user” tuple. You have used “%d” placeholders, which is incorrect . Instead you should use %s for all datatypes.
Above code will resolve the "Not all parameters were used" error and data will be inserted correctly.