Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- con=sqlite3.connect("check.db")
- c=con.cursor()
- class sample():
- def __init__(self):
- print("LOGIN:")
- self.check()
- def check(self):
- username=input("Enter the username: ")
- c.execute("select * from user where username='"+str(username)+"'")
- for row in c.fetchall():
- print("WELCOME "+str(username)+" ")
- print("MAIN MENU \n1-->CASH WITHDRAWL\n2-->BALANCE ENQUIRY\n3-->TRANSFER")
- check=int(input("Enter the choice: "))
- withdraw=int()
- password=int()
- if check==1:
- withdraw=input("enter the amount: ")
- password=input("Enter the password:")
- c.execute("select * from user where pass='"+str(password)+"'")
- for row in c.fetchall():
- c.execute("update user set balance=balance-'"+str(withdraw)+"' where username='"+str(username)+"'")
- c.execute("insert into transactions (from_,amount)values(?,?)",(username,withdraw))
- print("completed")
- elif check==2:
- password=input("Enter the password:")
- c.execute("select * from user where pass='"+str(password)+"'")
- for row in c.fetchall():
- print(row[2])
- elif check==3:
- password=input("Enter the password:")
- user=input("enter the username to which u want to transfer:")
- transfer=int(input("Enter the amount to be transferred:"))
- c.execute("select * from user where pass='"+str(password)+"'")
- for row in c.fetchall():
- c.execute("update user set balance=balance-'"+str(transfer)+"' where username='"+str(username)+"' ")
- c.execute("update user set balance=balance+'"+str(transfer)+"' where username='"+str(user)+"' ")
- c.execute("insert into transactions (from_,to_,amount)values(?,?,?)",(username,user,transfer))
- print("completed")
- else:
- print("not completed")
- con.commit()
- c.close()
- con.close()
- o1=sample()
Add Comment
Please, Sign In to add comment