I having some issues to update my database, it keeps throwing the same error
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 'WHERE ID = id' at line 10
The database update function.
def update():
display_db()
cursor = employee_db.cursor()
id = int(input('Selected Employee ID to be updated: '))
sql = "SELECT * FROM employee_db.employee_data;"
db_conn = create_engine("mysql+mysqldb://root:root@localhost/employee_db")
data = pd.read_sql_query(sql, db_conn)
df = pd.DataFrame(data)
name = input('Enter the Empoyee name: ')
surname = input('Enter Empoyee surname: ')
address = input('Enter Empoyee address: ')
credentials = input('Enter Empoyee credentials: ')
department = input('Enter Empoyee department: ')
hr_rate = input('Enter Empoyee hourly rate: ')
email = name[0] + surname + '@avengers.av'
email = email.lower()
emp = [{
'ID': id,
'Name': name,
'Surname': surname,
'Address': address,
'Credentials': credentials,
'Department': department,
'Hourly_rate': hr_rate,
'email': email
}]
# Update employee
updated_employee = """UPDATE employee_db
SET ID = id,
Name = name,
Surname = surname,
Address = address,
Credentials = credentials,
Department = department,
Hourly_rate = hr_rate,
email = email,
WHERE ID = id;
cursor.execute(updated_employee)
employee_db.commit()
display_db()
Any help will be the most appreciated.
Note that the top part was used to insert data in the database and it worked without any issue.
See link to screenshot of error.