#!/usr/bin/env python
#Author:windtalker
import os, getpass
import sqlite3
from time import ctime
print(ctime())
conn = sqlite3.connect('usercheck.db')
cursor = conn.cursor()
# is_exist = cursor.execute("select * from sqlite_master where type='table' and name = 'users'")
rows = cursor.execute("SELECT * FROM users").fetchall()
print(rows)
uname = input('username:')
try_times = 1
while try_times <= 3:
passwd = getpass.getpass('password:')
row = cursor.execute("SELECT * FROM users where username = '%s'" % (uname)).fetchone()
if row and row[2] == 1:
print('The account is locked!')
break
elif row and row[1] == passwd:
print('Login successful,welcome %s' % uname)
break
elif try_times < 3:
print('username or password is not right!Try again!')
try_times += 1
else:
updates = cursor.execute("update users set islock = 1 where username = '%s'" % uname)
conn.commit()
if updates.rowcount > 0:
print('The account %s will be locked!' % uname)
print('You have tried three times! Goodbye!')
cursor.close()
conn.close()