Python Forum
User Update in Mysql with python
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
User Update in Mysql with python
#1
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
Reply
#2
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
Reply
#3
I solved the problem
Reply
#4
Good! How did you solve it?
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020