Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 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.  
  26. conn = sqlite3.connect('OS_employee.db')
  27. with conn:
  28. cur = conn.cursor()
  29. print("successfully connected")
  30. existingUser = input("Existing user?[yes/no]")
  31. if existingUser == "no":
  32. try:
  33. EmployeeID = int(input("Enter New Employee ID: "))
  34.  
  35.  
  36. FirstName = input("What's your first name:")
  37. FirstName = FirstName.title()
  38.  
  39. LastName = input("what's your last name: ")
  40. LastName = LastName.title()
  41.  
  42. Email = input("Email: ")
  43. Email = Email.lower()
  44.  
  45. Password = input("Enter a password: ")
  46. Password = Password.lower()
  47.  
  48. cur.execute(
  49. 'insert into employee values(?,?,?,?,?)',
  50. (EmployeeID, FirstName, LastName, Email, Password))
  51.  
  52. cur.execute(
  53. 'select * from employee where EmployeeId=?',
  54. (EmployeeID,))
  55.  
  56. results = cur.fetchall()
  57. print(results)
  58.  
  59. except sqlite3.IntegrityError:
  60. print("Connection Failed")
  61. else:
  62. login()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement