Python Forum

Full Version: User Update in Mysql with python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have a problem. My library mysql-connector

my code working but doesnt updating table

if passentry != "":
    query=("UPDATE customer SET passw = %s WHERE mail = %s")
    value= (passentry2,mailal)
    mycursor2.execute(query,value)
    veritab.commit()

elif nameentry != "":
    query=("UPDATE customer SET name= %s WHERE mail = %s")
    value= (nameentry2,mailal)
    mycursor2.execute(query,value)
    veritab.commit()

elif surnameentry!= "":
    query=("UPDATE customer SET surname= %s WHERE mail = %s")
    value= (surnameentry2,mailal)
    mycursor2.execute(query,value)
    veritab.commit()

else:
    pass
your if statement is weird.
what if passentry == "" and nameentry == ""
nameentry will never execute nor will the third condition
you should test same variable for different values/ otherwise you should use just ifs, no elifs
I solved the problem
Good! How did you solve it?