0% found this document useful (0 votes)
10 views15 pages

Reall

Uploaded by

ykhandelwal2007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views15 pages

Reall

Uploaded by

ykhandelwal2007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

import mysql.

connector as ms

mydb=ms.connect(host="localhost",user="root",passwd="12345",data
base="bank")

mc=mydb.cursor()

mc.execute("select * from details;")

mc.fetchall()

count=mc.rowcount

#Functions

def display():

mc.execute("select * from details;")

mc.fetchall()

count=mc.rowcount

mc.execute("select * from details;")

rec=mc.fetchall()

print("All the records are:-")

for i in range(0,count):
print(rec[i])

def insert():

a='y'

while a in 'yY':

b=int(input("Enter the Account No.-"))

c=input("Enter the Name of the accountant-")

d=int(input("Enter the current balance (Should be greater than


5000) -"))

e=input("Enter the address of the accountant-")

f=int(input("Enter the mobile no.-"))

if d>=5000:

mc.execute("insert into details


values('{}','{}','{}','{}','{}',0);".format(b,c,d,e,f))

mc.execute("commit;")

else:

print("Invalid details! The minimum current balance has to be


5000!")

print(" ")

a=input("Do you want to continue inserting: y/n: ")


mc.execute("select * from details")

rec2=mc.fetchall()

print(" ")

print("The updated records are:-")

mc.execute("select * from details;")

mc.fetchall()

count=mc.rowcount

for i in range(0,count):

print(rec2[i])

def modify():

m=int(input("Enter the account no. of the record you want to


modify:-"))

check="NO"

mc.execute("select acc_no from details;")

recc=mc.fetchall()

mc.execute("select * from details;")

mc.fetchall()

count=mc.rowcount
for i in range(0, count):

if m==recc[i][0]:

check="YES"

if check=="YES":

print("What do you want to update:-")

print("1. Name")

print("2. Current Balance")

print("3. Address")

print("4. Mobile no.")

n=int(input("Enter your choice-"))

if n==1:

o=input("Enter the new name-")

mc.execute("update details set name='{}' where


acc_no='{}';".format(o,m))

mc.execute("commit;")

elif n==2:

o=input("Enter the new current balance-")

mc.execute("update details set c_bal='{}' where


acc_no='{}';".format(o,m))

mc.execute("commit;")
elif n==3:

o=input("Enter the new address-")

mc.execute("update details set address='{}' where


acc_no='{}';".format(o,m))

mc.execute("commit;")

elif n==4:

o=input("Enter the new mobile no.-")

mc.execute("update details set mob='{}' where


acc_no='{}';".format(o,m))

mc.execute("commit;")

else:

print("Enter a valid choice!")

mc.execute("select * from details")

rec2=mc.fetchall()

mc.execute("select * from details;")

mc.fetchall()

count=mc.rowcount

print(" ")

print("The updated records are:-")

for i in range(0,count):
print(rec2[i])

else:

print("This account number doesn't exist.")

def delete():

j=int(input("Enter the account no. of the record you want to


delete-"))

check="NO"

mc.execute("select acc_no from details;")

recc=mc.fetchall()

mc.execute("select * from details;")

mc.fetchall()

count=mc.rowcount

for i in range(0, count):

if j==recc[i][0]:

check="YES"

if check=="YES":

mc.execute("delete from details where acc_no='{}';".format(j))

mc.execute("commit;")

mc.execute("select * from details")


rec2=mc.fetchall()

mc.execute("select * from details;")

mc.fetchall()

count=mc.rowcount

print(" ")

print("The updated records are:-")

for i in range(0,count):

print(rec2[i])

else:

print("This account number doesn't exist.")

def search():

p=int(input("Enter the account no. of the record you want to


search-"))

check="NO"

mc.execute("select acc_no from details;")

recc=mc.fetchall()

for i in range(0, count):

if p==recc[i][0]:

check="YES"
if check=="YES":

mc.execute("select * from details where acc_no='{}';".format(p))

print("The record you want to see is-")

rec=mc.fetchall()

print(rec)

else:

print("This account number doesn't exist.")

def transaction():

d=int(input("Enter you account no.-"))

check="NO"

mc.execute("select acc_no from details;")

recc=mc.fetchall()

for i in range(0, count):

if d==recc[i][0]:

check="YES"

if check=="YES":

print("What do you want to do-")

print("1- Withdraw")

print("2- Deposit")
e=int(input("Enter your choice-"))

mc.execute("select c_bal from details where


acc_no='{}';".format(d))

rec3=mc.fetchall()

if e==1:

a=int(input("Enter the amount you want to withdraw-"))

if (rec3[0][0]-a)>=5000:

mc.execute("update details set last_tran='-{}' where


acc_no='{}';".format(a,d))

mc.execute("commit;")

mc.execute("update details set c_bal=c_bal-'{}' where


acc_no='{}';".format(a,d))

mc.execute("commit;")

mc.execute("select * from details where


acc_no='{}';".format(d))

rec2=mc.fetchall()

print("The updated records are:-\n",rec2)

else:

mc.execute("select c_bal-5000 from details where


acc_no='{}';".format(d))

rec5=mc.fetchall()
print("Insufficient balance. The maximum you can withdraw is:
",rec5[0][0])

elif e==2:

a=int(input("Enter the amount you want to deposit-"))

mc.execute("update details set last_tran='{}' where


acc_no='{}';".format(a,d))

mc.execute("commit;")

mc.execute("update details set c_bal=c_bal+'{}' where


acc_no='{}';".format(a,d))

mc.execute("commit;")

mc.execute("select * from details where acc_no='{}';".format(d))

rec2=mc.fetchall()

print("The updated records are:-\n",rec2)

else:

print("Please enter a valid choice! ")

else:

print("This account number doesn't exist.")

def history():
a=int(input("Enter your account no.-"))

mc.execute("select name from details where acc_no =


'{}';".format(a))

rec=mc.fetchall()

print("Accountant Name - ",rec[0][0])

mc.execute("select c_bal from details where acc_no = '{}';".format(a))

rec=mc.fetchall()

print("Current Balance - ",rec[0][0])

mc.execute("select address from details where acc_no =


'{}';".format(a))

rec=mc.fetchall()

print("Address - ",rec[0][0])

mc.execute("select mob from details where acc_no = '{}';".format(a))

rec=mc.fetchall()

print("Mobile no. - ",rec[0][0])

mc.execute("select last_tran from details where acc_no =


'{}';".format(a))

rec=mc.fetchall()

print("Last Transaction - ",rec[0][0])


#Main Command Block

print("1-Admin")

print("2-Client")

a=int(input("Enter your choice:-"))

if a==1:

b=input("Enter passkey:-")

if b=="admin@123":

print(" MAIN MENU")

print(" 1. Display all the records of customers")

print(" 2. Insert a new record ")

print(" 3. Search a record")

print(" 4. Modify an existing record")

print(" 5. Delete an existing record")

print(" 6. Exit")

res='y'

while res in ("yY"):

x=int(input("Enter your choice : "))

if x==1:
display()

elif x==2:

insert()

elif x==3:

search()

elif x==4:

modify()

elif x==5:

delete()

elif x==6:

print("Thank You! Have a nice day!")

break

else:

print("Please enter a valid choice!")

print(" ")

res=input("DO YOU WANT TO CONTINUE(y/n):-")

print(" ")
else:

print("Invalid Passkey!!")

elif a==2:

print(" MAIN MENU")

print(" 1. Do a Transaction")

print(" 2. Show Passbook")

print(" 3. Exit")

res='y'

while res in ("yY"):

x=int(input("Enter your choice : "))

if x==1:

transaction()

elif x==2:

history()

elif x==3:

print("Thank You! Have a nice day!")

break

else:

print("Please enter a valid choice!")

print(" ")
res=input("DO YOU WANT TO CONTINUE(y/n):-")

print(" ")

You might also like