I'm trying to do a function that updates a database through a form but I'm getting this error: ValueError: operation parameter must be str.
I have no problem with other functions like delete, read or insert and I don´t know how to fix this problem. I put down two versions of function update and respective errors.
I'm trying this:
def actualizaDatos():
Id1 = clave.get()
nombre1 = nombre.get()
password1 = password.get()
apellido1 = apellido.get()
direccion1 = direccion.get()
comentarios1 = comentarios.get()
sentencia="UPDATE DATOSUSUARIOS SET ID= ?, NOMBRE_USUARIO = ?, PASSWORD = ?, APELLIDO = ?, DIRECCION = ?, COMENTARIOS = ? WHERE ID=?", [clave.get()]
miCursor.execute(sentencia, [Id1, nombre1, password1, apellido1, direccion1, comentarios1])
I expected the database to update but I get this error:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\John\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "Practica_Guiada.py", line 148, in actualizaDatos
miCursor.execute(sentencia, [Id1,nombre1, password1, apellido1, direccion1, comentarios1])
ValueError: operation parameter must be str
sentenciato a tuple because you have, [clave.get()]at the end of the assignment. What is that for?cursor.execute()is not of type String although it is required by the database. Have a look at the table definition and at the actual values that are passed to the query and see if the types are valid., [clave.get()]remove this fromsentencia