Guest User

Untitled

a guest
Jul 3rd, 2018
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. import sqlite3
  2. con=sqlite3.connect("check.db")
  3. c=con.cursor()
  4. class sample():
  5. def __init__(self):
  6. print("LOGIN:")
  7. self.check()
  8.  
  9. def check(self):
  10. username=input("Enter the username: ")
  11. c.execute("select * from user where username='"+str(username)+"'")
  12. for row in c.fetchall():
  13. print("WELCOME "+str(username)+" ")
  14. print("MAIN MENU \n1-->CASH WITHDRAWL\n2-->BALANCE ENQUIRY\n3-->TRANSFER")
  15. check=int(input("Enter the choice: "))
  16. withdraw=int()
  17. password=int()
  18. if check==1:
  19. withdraw=input("enter the amount: ")
  20. password=input("Enter the password:")
  21. c.execute("select * from user where pass='"+str(password)+"'")
  22. for row in c.fetchall():
  23. c.execute("update user set balance=balance-'"+str(withdraw)+"' where username='"+str(username)+"'")
  24. c.execute("insert into transactions (from_,amount)values(?,?)",(username,withdraw))
  25. print("completed")
  26. elif check==2:
  27. password=input("Enter the password:")
  28. c.execute("select * from user where pass='"+str(password)+"'")
  29. for row in c.fetchall():
  30. print(row[2])
  31. elif check==3:
  32. password=input("Enter the password:")
  33. user=input("enter the username to which u want to transfer:")
  34. transfer=int(input("Enter the amount to be transferred:"))
  35. c.execute("select * from user where pass='"+str(password)+"'")
  36. for row in c.fetchall():
  37. c.execute("update user set balance=balance-'"+str(transfer)+"' where username='"+str(username)+"' ")
  38. c.execute("update user set balance=balance+'"+str(transfer)+"' where username='"+str(user)+"' ")
  39. c.execute("insert into transactions (from_,to_,amount)values(?,?,?)",(username,user,transfer))
  40. print("completed")
  41. else:
  42. print("not completed")
  43.  
  44. con.commit()
  45. c.close()
  46. con.close()
  47.  
  48. o1=sample()
Add Comment
Please, Sign In to add comment