I need to check if table which holds credentials has record with matched username and password. I use COUNT because it's easier to parse one int value. How to check (using Python) if there are 1 or more records in credentials table?
query = "SELECT COUNT(user_name) from credentials user_name='[email protected]' and pwd='123';"
con = sqlite.connect(databasefile)
cur = con.cursor()
cur.execute(query)
while 1:
row=cur.fetchone()
if not row:
break
res=res+[row]
#check if there is 1 or more matched records ....
It's the result from server:
sqlite> SELECT COUNT(user_name) from credentials where user_name='[email protected]' and pwd='1 23';
COUNT(user_name)
----------------
1