-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.py
More file actions
116 lines (98 loc) · 3.7 KB
/
Copy pathProject.py
File metadata and controls
116 lines (98 loc) · 3.7 KB
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
110
111
112
113
114
115
116
import sqlite3
def intro():
print("\n\n\n\t\t\t\t**********************")
print("\t\t\t\tBANK MANAGEMENT SYSTEM")
print("\t\t\t\t**********************")
intro()
try:
con = sqlite3.connect('Banking.sqlite3')
cur = con.cursor()
ls = []
depst=[]
new_account=[]
d=[]
#cur.execute("create table Bank (Acno int, Name text, Balance int)")
while True:
ch = int(input("\n\nEnter operation to perform :\n\n1) DEPOSIT \n\n2) WITHDRAWL \n\n3) ADD ACCOUNT \n\n4) DELETE ACCOUNT \n\n5) SHOW_DETAILS\n\n6) UPDATE DETAILS \n\n7) Quit\n\nYour Choice :-> "))
if ch==1:
ac = int(input("Enter your account number :--> "))
ls.append(ac)
dep = int(input("Enter the amount to deposit :--> "))
cur.execute('select Balance from Bank where Acno = (?)',ls)
bl = cur.fetchone()
dep= bl[0] + dep
depst.append(dep)
depst.append(ac)
cur.execute('Update Bank set Balance = (?) where Acno = (?)',depst)
print("\nDeposit Completed\n")
ls.pop()
depst.pop()
con.commit()
elif ch==2:
ac = int(input("Enter your account number :--> "))
ls.append(ac)
wid = int(input("Enter the amount to withdraw :--> "))
cur.execute('select Balance from Bank where Acno = (?)',ls)
bal = cur.fetchone()
old_balance = []
old_balance.append(bal[0])
if old_balance[0]<wid:
print("Insufficient amount")
else:
new_bal=old_balance[0]-wid
old_balance.pop()
old_balance.append(new_bal)
old_balance.append(ac)
cur.execute('Update Bank set Balance = (?) where Acno =(?) ',old_balance)
print("\nWithdrawl Completed \n")
del ls[0:]
del old_balance[0:]
con.commit()
con.close()
elif ch==3:
print("Enter -> Acno , Name, Intial Balance\n")
for i in range(0,3):
x = input("Enter value:-> ")
new_account.append(x)
cur.execute('insert into Bank values (?,?,?)',new_account)
con.commit()
del new_account[0:]
elif ch==4:
dl = input("Enter account number to delete :-> ")
d.append(dl)
cur.execute('DELETE from Bank where Acno = (?)',d)
del d[0:]
con.commit()
elif ch==5:
choice = input("Press 'A' for all customer details or enter particular Name of Person :-> ")
na=[]
na.append(choice)
if choice== 'A':
with con:
cur.execute('SELECT * FROM Bank')
rows = cur.fetchall()
print("Total records",len(rows))
for row in rows:
print("\n",row)
else:
cur.execute('SELECT * FROM Bank where Name =(?)',na)
rows = cur.fetchall()
for row in rows:
print("\n",row)
elif ch==6:
ac = input("Enter Account Number to do updation:-> ")
nm = input("\nEnter new Name:-> ")
ls = []
ls.append(nm)
ls.append(ac)
cur.execute('UPDATE Bank set Name=(?) where Acno=(?)',ls)
con.commit()
elif ch==7:
print("Quit")
con.commit()
con.close()
break
else:
print("Invalid input")
except Exception as err:
print(err)