Python Forum

Full Version: else problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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")
Please use proper code tags while posting your thread
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")
The code shown does not define x or resultat so there is no evidence that the if statement should be true.