Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
else problem
#1
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")
Reply
#2
Please use proper code tags while posting your thread
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#3
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")
Reply
#4
The code shown does not define x or resultat so there is no evidence that the if statement should be true.
Reply


Forum Jump:

User Panel Messages

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