Guest User

Untitled

a guest
Nov 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. import mysql.connector as con
  2.  
  3. class credential(object):
  4.  
  5. def __init__(self):
  6. self.db= con.connect(
  7. host = "localhost",
  8. user = "root",
  9. password = "snehasindhu@3",
  10. database = "pro"
  11. )
  12. self.cur = self.db.cursor(buffered=True)
  13.  
  14.  
  15. def login(self, mail, passs):
  16. mail_t = (mail,)
  17. self.cur.execute('select uid from user1 where umail=%s',mail_t)
  18. uid_fet = self.cur.fetchone()
  19. if uid_fet == None:
  20. return False
  21. elif len(uid_fet) == 0:
  22. return False
  23. else:
  24. self.cur.execute('select upass from user1 where uid=%s',uid_fet)
  25. upass_fet = self.cur.fetchone()
  26. up = upass_fet[0]
  27. if up == passs:
  28. return True
  29. else:
  30. return False
  31.  
  32.  
  33. def signin(self, mail):
  34. sql = "select * from user1 where umail=%s"
  35. val = (mail,)
  36. self.cur.execute(sql,val)
  37. us_fet = self.cur.fetchall()
  38. if us_fet == None:
  39. return False
  40. elif len(us_fet) == 0:
  41. return False
  42. else:
  43. return True
Add Comment
Please, Sign In to add comment