Skip to content

Commit 22daf74

Browse files
authored
Add files via upload
1 parent 19b0fbe commit 22daf74

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

Bank Management.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ def account_creation():
122122
acc_bal = int(input('Enter the current account balance: '))
123123

124124

125-
cur.execute('insert into customer_details(Customer_ID, Customer_Name, Account_Number, Account_Balance) values (%d, %s, %d, %d);', (cus_id, name, acc_no, acc_bal))
126-
cur.execute('commit')
125+
cur.execute('insert into customer_details(Customer_ID, Customer_Name, Account_Number, Account_Balance) values ({}, "{}", {}, {});'.format(cus_id, name, acc_no, acc_bal))
126+
cur.execute('commit')
127127

128128

129129
def del_account():
@@ -134,15 +134,33 @@ def del_account():
134134
account_no = int(input("Enter the Account Number: "))
135135
confirmation = input("Are you sure?(Y/n): ")
136136

137-
if confirmation.lower() == 'n':
138-
del_account_cmd = 'delete from customer_id where Account_Number = %s' %(account_no)
137+
if confirmation.lower() == 'y':
138+
del_account_cmd = 'delete from customer_details where Account_Number = %s' %(account_no)
139139
cur.execute(del_account_cmd)
140140
cur.execute('commit')
141141

142142
else:
143143
print("Request Cancelled")
144144

145145

146+
def display_details():
147+
'''
148+
This function prints/displays the details of a bank account
149+
'''
150+
151+
account_no = int(input("Enter Account Number: "))
152+
153+
retrieve_record = 'select * from customer_details where Account_Number = %s' %(account_no)
154+
cur.execute(retrieve_record)
155+
details = cur.fetchall()
156+
157+
for i in details:
158+
print("CUSTOMER DETAILS FOR ACCOUNT NUMBER:", account_no," \n")
159+
print("CUSTOMER ID:", i[0])
160+
print("NAME:", i[1])
161+
print("ACCOUNT NUMBER:", i[2])
162+
print("ACCOUNT BALANCE:", i[3])
163+
146164
ans = 'y'
147165
while ans.lower() == 'y':
148166
print("\n\t\t\t\t\tMAIN MENU\n")
@@ -160,11 +178,13 @@ def del_account():
160178
del_account()
161179

162180
elif choice == 4:
163-
pass
181+
display_details()
164182

165183
else:
166184
print("Invalid Menu option entered")
167185

168186
print()
169187
ans = input("Do you wish to continue?(Y/n): ")
170-
print()
188+
print()
189+
190+
conobj.close()

0 commit comments

Comments
 (0)