mercredi 24 avril 2019

Python if statement keeps giving else output even when conditions are met

If statement keeps skipping to else even when the conditions are met. I think it might be the

if c1 == 1:

as one has not been defined anywhere

this is my command and if statement:

c1 = "Select * From tag_logs where reader_id = 'Reader_001' and timestamp > '" + str(t) +"' and tag_no = '55992086130'"
c1 = mycursor.fetchone()
#print(c1)
#mycursor.execute("Select * From tag_logs where reader_id = 'Reader_001' and timestamp >='" + str(t) +"' and tag_no = '55992086130'")

cursor = mydb.cursor(buffered=True)

if c1 == 1:   
    ser.write(b'H')
    print('done')

else:
   ser.write(b'L')
   print('deny')

mycursor.execute(c1)

Aucun commentaire:

Enregistrer un commentaire