Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- def register():
- with conn:
- cur = conn.cursor()
- try:
- EmployeeID = int(input("Enter New Employee ID: "))
- FirstName = input("What's your first name:")
- FirstName = FirstName.title()
- LastName = input("what's your last name: ")
- LastName = LastName.title()
- Email = input("Email: ")
- Email = Email.lower()
- Password = input("Enter a password: ")
- Password = Password.lower()
- cur.execute(
- 'insert into employee values(?,?,?,?,?)',
- (EmployeeID, FirstName, LastName, Email, Password))
- cur.execute(
- 'select * from employee where EmployeeId=?',
- (EmployeeID,))
- results = cur.fetchall()
- print(results)
- except sqlite3.IntegrityError:
- print("Connection Failed")
- def login():
- with conn:
- cur = conn.cursor()
- try:
- loginTest = False # main condition to loop if email and password not met
- while not loginTest: # wrong email loopy
- userEmail = input("Email please: ")
- userEmail = userEmail.replace(" ", "")
- userPassword = input("Password: ")
- userPassword = userPassword.strip()
- cur.execute(
- "SELECT COUNT (*) FROM Employee WHERE(Email= '" + userEmail.lower() + "' AND Password= '" + userPassword + "')")
- results = cur.fetchone() # return very first thing it finds that matches
- print(results[0]) # print first thing
- if results[0] == 1:
- print("login successful")
- loginTest = True
- else:
- print("no login bithc")
- existingUser = input("Existing user?[yes/no]")
- if existingUser == "no":
- register()
- except:
- print("connection failed")
- conn = sqlite3.connect('OS_employee.db')
- with conn:
- cur = conn.cursor()
- print("successfully connected")
- existingUser = input("Existing user?[yes/no]")
- if existingUser == "no":
- register()
- else:
- login()
Add Comment
Please, Sign In to add comment