-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBank.py
64 lines (62 loc) · 2.56 KB
/
Bank.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import mysql.connector as con
db=con.connect(host="localhost",user="root",password="root",database="mydb")
cur=db.cursor()
st=1
while(st==1):
print"Press 1 to register"
print"Press 2 to login:"
ip=input("Enter yor choice:")
if(ip==1):
user_id=raw_input("Enter the user id of the customer:")
user_name=raw_input("Enter the name of the customer:")
user_acc=raw_input("Enter the account number of the customer:")
user_add=raw_input("Enter the address of the customer:")
user_pass=raw_input("Enter the password of the user:")
q="insert into bank(userid, Name, accontno, address, password, balance) values(%s,%s,%s,%s,%s,%s)"
v=[user_id,user_name,user_acc,user_add,user_pass,0]
cur.execute(q,v)
db.commit()
if(ip==2):
user_acc=raw_input("Enter the account number of the user:")
usp="select accontno from bank"
cur.execute(usp)
d=cur.fetchall()
for i in range(len(d)):
if(user_acc==d[i][0]):
acc=user_acc
if(acc==user_acc):
passw=raw_input("Enter the password of the user")
pass_w="select password from bank"
cur.execute(pass_w)
d=cur.fetchall()
pa=d[0][0]
if(pa==passw):
print"Login successfull"
print"press 1 to add money in the account:"
print"Press 2 to tranfer money from the account:"
print"Press 3 to print the passbook:"
print"Press 4 to exit :)"
log=input("Enter your choice:")
if(log==1):
mon=input("Enter the amount of money you want to add:")
fet_mo="select balance from bank where accontno="+user_acc+""
cur.execute(fet_mo)
fetc_mo=cur.fetchone()
amt=int(fetc_mo[0])+mon
amt=str(amt)
print amt
quee="update bank set balance='"+amt+"' where accontno="+user_acc+""
cur.execute(quee)
db.commit()
if(log==3):
que="select balance from bank where accontno="+user_acc+""
cur.execute(que)
que_bal=cur.fetchone()
db.commit()
print "The balance is",que_bal[0]
if(log==4):
break
else:
print"wrong username"
st=input("Press 1 to continue:")
print"Thanks"