I am trying to make a clock in system that the user inputs a key and it compares it to an sqlite database.
The problem I am having is when comparing the key entered to the one on the database. I am assuming it is because the sqlite query returns a tuple. I thought putting it into a for loop would sort it out. Although they match they come back as false.
import sqlite3 as lite
conn = lite.connect('attendance.db')
c = conn.cursor()
r = raw_input('Awaiting Key: ')
keyCode = str(int(r))
q = c.execute("SELECT key FROM employees WHERE key = '%s'") % keyCode
for i in q:
if i == r:
print 'open'
else:
print 'closed'
Aucun commentaire:
Enregistrer un commentaire