First ERROR message:
mysql.connector.errors.DataError: 1292 (22007): Truncated incorrect DOUBLE value:
\----------------------------------------------------------------------------------------------
I have tried several times to find a solution online and have seen other users who have had the same problem.
Unfortunately, it hasn't solved my problem yet. I've Googled to find a solution similar to my problem and that hasn't helped either.
Okay, the problem is that I keep getting errors from pycharm which are as follows
mysql.connector.errors.DataError: 1292 (22007): Truncated incorrect DOUBLE value:
What does this mean specifically?
Is there something wrong with my database?
What is it?
Here is my table that I have 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`)
);
And I want to update a user with python.
The coding is as follows:
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.
Have seen other solutions on Stackoverflow that are similar to my problem.
Have Googled my way with the Error coding.
Changed my table on mysql.
You have wrong order in your data:
The placeholder for emp_id is the last one, but you have your value in first position, so you need to change it. Also I removed some brackets not needed and some comma