else problem - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: else problem (/thread-26462.html) |
else problem - MJB - May-02-2020 Hello sorry for my English because I am french. I have a problem when I run the program and I enter the right code that is "10" it doesn't change the state of presence, but on the contrary, it shows me directly: "the code is not in the database" I don't understand too much because it has to change my state from 0 to 1 in my database but my program runs as if I didn't enter the right code. If you could help me with that I would be eternally grateful. look my programm: if (x) in (resultat): operation= ("SELECT * FROM enfants3; UPDATE enfants3 SET presence=""1"" WHERE RFID= 10") for result in cursor.execute(operation, multi=True): result.with_rows print("Rows produced by statement '{}':".format( result.statement)) print(result.fetchall()) print("Number of rows affected by statement '{}': {}".format( result.statement, result.rowcount)) else: print("the code is not in my database") RE: else problem - pyzyx3qwerty - May-02-2020 Please use proper code tags while posting your thread RE: else problem - MJB - May-02-2020 Hello sorry for my English because I am french. I have a problem when I run the program and I enter the right code that is "10" it doesn't change the state of presence, but on the contrary, it shows me directly: "the code is not in the database" I don't understand too much because it has to change my state from 0 to 1 in my database but my program runs as if I didn't enter the right code. If you could help me with that I would be eternally grateful. look my programm: if (x) in (resultat): operation= ("SELECT * FROM enfants3; UPDATE enfants3 SET presence=""1"" WHERE RFID= 10") for result in cursor.execute(operation, multi=True): result.with_rows print("Rows produced by statement '{}':".format( result.statement)) print(result.fetchall()) print("Number of rows affected by statement '{}': {}".format( result.statement, result.rowcount)) else: print("the code is not in my database") RE: else problem - Yoriz - May-02-2020 The code shown does not define x or resultat so there is no evidence that the if statement should be true.
|