Edit => Problem resolve : I changed my query to this and now it's working thank you yall:
query_update = ("UPDATE comments SET label = '%s' WHERE id = %s"%(new_label, id))
I'm working on a school project to update a mysql database thru a form in a flask app.
While I run my query updating a column to an integer it works, but when my query is a string it doesn't.
I only know a little about mysql and even less about mysql workench.
Thanking in advance.
Here is my code :
cur_update = cnx.cursor(buffered=True)
#working
query_update = ("UPDATE comments SET label = %s WHERE id = %s"%(1, id))
#working
query_update = ("UPDATE comments SET label = %s WHERE id = %s"%("1", id))
#not working
query_update = ("UPDATE comments SET label = %s WHERE id = %s"%("test", id))
#returing the following error
mysql.connector.errors.ProgrammingError: 1054 (42S22): Unknown column 'test'
in 'field list'
cur_update.execute(query_update)
cnx.commit()
cur_update.close()
cnx.close()
I tried several datatype for the concern column but every one of them return the same error.