0
Guys I’m having a problem with the command on UPDATE, I’m using Python 3.8.5 and mysql 5.7.31.
value_id = 10
value_column = 'nome'
ID = 'rodrigo'
comando_sql = "UPDATE user SET %s='%s' WHERE id=%s"
value = (str(value_column),str(ID),str(value_id))
cursor.execute(comando_sql,value)
Database.commit()
But he makes that mistake: mysql.connector.errors.Programmingerror: 1064 (42000): 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 '''name'=''Rodrigo'' WHERE id='10'' at line 1
And the funny thing when I type cursor.execute("UPDATE user SET nome = 'rodrigo' WHERE id=10")
he accepts without error.
Display the
comando_sql
generated that will surely identify the error.– anonimo