Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. import sqlite3
  2.  
  3. def login():
  4. with conn:
  5. cur = conn.cursor()
  6. try:
  7. loginTest = False # main condition to loop if email and password not met
  8. while not loginTest: # wrong email loopy
  9. userEmail = input("Email please: ")
  10. userEmail = userEmail.replace(" ", "")
  11. userPassword = input("Password: ")
  12. userPassword = userPassword.strip()
  13. cur.execute(
  14. "SELECT COUNT (*) FROM Employee WHERE(Email= '" + userEmail.lower() + "' AND Password= '" + userPassword + "')")
  15. results = cur.fetchone() # return very first thing it finds that matches
  16. print(results[0]) # print first thing
  17. if results[0] == 1:
  18. print("login successful")
  19. loginTest = True
  20. else:
  21. print("no login bithc")
  22. except:
  23. print("connection failed")
  24.  
  25. conn = sqlite3.connect('OS_employee.db')
  26. with conn:
  27. cur = conn.cursor()
  28. print("successfully connected")
  29. existingUser = input("Existing user?[yes/no]")
  30. if existingUser == "no":
  31. try:
  32. EmployeeID = int(input("Enter New Employee ID: "))
  33.  
  34.  
  35. FirstName = input("What's your first name:")
  36. FirstName = FirstName.title()
  37.  
  38. LastName = input("what's your last name: ")
  39. LastName = LastName.title()
  40.  
  41. Email = input("Email: ")
  42. Email = Email.lower()
  43.  
  44. Password = input("Enter a password: ")
  45. Password = Password.lower()
  46.  
  47. cur.execute(
  48. 'insert into employee values(?,?,?,?,?)',
  49. (EmployeeID, FirstName, LastName, Email, Password))
  50.  
  51. cur.execute(
  52. 'select * from employee where EmployeeId=?',
  53. (EmployeeID,))
  54.  
  55. results = cur.fetchall()
  56. print(results)
  57.  
  58. except sqlite3.IntegrityError:
  59. print("Connection Failed")
  60. else:
  61. login()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement