-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBank Management System.py
109 lines (101 loc) · 2.95 KB
/
Bank Management System.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import mysql.connector as a
con = a.connect(host="localhost", user="root", passwd="*******", database="bank")
def main():
print("""
1. Open New Account
2. Deposit Amount
3. Withdraw Amount
4. Balance Enquiry
5. Display Customer Details
6. Close an Account
""")
choice = input("Enter Task No. : ")
if(choice == '1'):
openAcc()
elif(choice == '2'):
depoAmo()
elif(choice == '3'):
withAmo()
elif(choice == '4'):
balance()
elif(choice == '5'):
dispAcc()
elif(choice == '6'):
closeAcc()
else:
print("Wrong Input")
main()
def openAcc():
n = input("Enter Name : ")
ac = input("Enter Account No. : ")
db = input("Enter D.O.B (yyyy-mm-dd) : ")
p = input("Enter Phone No. : ")
ad = input("Enter Address : ")
ob = int(input("Enter Opening Balance : "))
data1 = (n,ac,db,p,ad,ob)
data2 = (n,ac,ob)
sql1 = 'insert into account values(%s,%s,%s,%s,%s,%s)'
sql2 = 'insert into amount values(%s,%s,%s)'
c = con.cursor()
c.execute(sql1,data1)
c.execute(sql2,data2)
con.commit()
print("Data Entered Successfully")
main()
def depoAmo():
am = int(input("Enter Amount : "))
ac = input("Enter Account No. : ")
a = 'select balance from amount where acno = %s'
data = (ac,)
c = con.cursor()
c.execute(a,data)
myresult = c.fetchone()
tam = myresult[0] + am
sql = 'update amount set balance = %s where acno = %s'
d = (tam,ac)
c.execute(sql,d)
con.commit()
main()
def withAmo():
am = int(input("Enter Amount : "))
ac = input("Enter Account No. : ")
a = 'select balance from amount where acno = %s'
data = (ac,)
c = con.cursor()
c.execute(a,data)
myresult = c.fetchone()
tam = myresult[0] - am
sql = 'update amount set balance = %s where acno = %s'
d = (tam,ac)
c.execute(sql,d)
con.commit()
main()
def balance():
ac = input("Enter Account No. : ")
a = 'select balance from amount where acno = %s'
data = (ac,)
c = con.cursor()
c.execute(a,data)
myresult = c.fetchone()
print("Balance Amount of Account: ",ac," is",myresult[0])
main()
def dispAcc():
ac = input("Enter Account No. : ")
a = 'select * from amount where acno = %s'
data = (ac,)
c = con.cursor()
c.execute(a,data)
myresult = c.fetchone()
for i in myresult:
print(i,end=" ")
main()
def closeAcc():
ac = input("Enter Account No. : ")
sql1 = 'delete from account where acno = %s'
sql2 = 'delete from amount where acno = %s'
data = (ac,)
c = con.cursor()
c.execute(sql1,data)
c.execute(sql2,data)
con.commit()
main()