Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- import sys
- import getpass
- sqlite_file = 'C:/Assignment/PADS/UROTS/urots_db.sqlite'
- users_tbl = 'USERS_TBL'
- toys_tbl = 'TOYS_TBL'
- conn = sqlite3.connect(sqlite_file)
- c = conn.cursor()
- def main():
- print('This module does not run by itself. Use urots_main.py')
- def login_check():
- try:
- username = input('Enter username: ')
- c.execute('SELECT * from {} WHERE username="{}"'.format(users_tbl, username))
- row = c.fetchone()
- if row is None:
- print('User "{}" does not exists!!!'.format(username))
- sys.exit()
- pass_try = 0
- while pass_try < 3:
- password = getpass.getpass()
- if password == row[2]:
- break
- elif password != row[2] and pass_try < 2:
- print('Incorrect password, try again...')
- elif pass_try == 2 and password != row[2]:
- print('Too manu retries. Exiting program...')
- sys.exit()
- pass_try += 1
- role = row[3]
- global user_id
- user_id = row[0]
- return role
- except sqlite3.Error as e:
- print('An error has occurred:', e.args[0])
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement