First error message:
mysql.connector.errors.DataError: 1292 (22007): 截断错误的DOUBLE值: \----------------------------------------------------------------------------------------------
I have tried many times to find a solution online and have seen other users encounter the same problem.
Unfortunately, this hasn't solved my problem. I've found a similar solution to my problem by googling, but that didn't help either.
Well, the problem is that I keep getting the following error from pycharm:
mysql.connector.errors.DataError: 1292 (22007): 截断错误的DOUBLE值:
What exactly does this mean?
Is there something wrong with my database?
what is the problem?
This is the table I created:
CREATE TABLE `employee` ( `emp_id` INTEGER NOT NULL, `emp_name` VARCHAR (17) NOT NULL, `emp_last_name` VARCHAR (17) NOT NULL, `emp_email` VARCHAR (17) NOT NULL, `emp_status` VARCHAR (17) NOT NULL, PRIMARY KEY (`emp_id`) );
I want to update a user using Python.
code show as below:
def update function(emp_id, emp_name, emp_last_name, emp_email, emp_status): emp_data = mysqlconn.cursor() sql_update_query = ("UPDATE employee set emp_name = %s, emp_last_name = %s, emp_email = %s, emp_status = %s WHERE emp_id = %s") updated_data = (emp_id, emp_name, emp_last_name, emp_email, emp_status) emp_data.execute(sql_update_query,updated_data,) mysqlconn.commit() print("Data Updated")
I don't see any syntax errors.
See other solutions to similar problems on Stackoverflow.
Did a Google search with the wrong encoding.
Changed my table on mysql.
You have the wrong order in your data:
The placeholder foremp_id is the last one, but you put the value in the first position, so you need to change that. Additionally, I removed some unnecessary parentheses and commas.