I'm trying to insert data into my mysql database, but I always get the error that something is wrong with the parameters, that I'd like to add into my insert statement, I tried all kinds of solutions and the one with the 's', 's' worked, it got inserted into my db.
Has anybody got an idea what can be wrong?
Thanks.
try:
conn = mysql.connect()
cursor = conn.cursor()
insert_cmd = "INSERT INTO TBTAB VALUES(%s, %s, %s, %s, %s)"
#insert_cmd = "INSERT INTO TBTAB VALUES('s', 's', 's', 's', 's')"
# insert_cmd = "INSERT INTO TBTAB VALUES(?, ?, ?, ?, ?)"
tpa= ("szilva", "barack", "meggye", "alma", "korte")
#cursor.execute("INSERT INTO TBTAB (UserName, Email, TextBoxCont, NodeChosen, CurDate) VALUES ('Caal', 'TomErichsen', 'Svanger', '400esd6', 'Nqdwasorway');")
cursor.execute(insert_cmd.format(tpa))
conn.commit()
return render_template('form.html')
except Exception as e:
return str(e)
error:
(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s, %s, %s, %s, %s)' at line 1")