Database Required
MySQL Database
SOURCE CODE
import random
import mysql.connector
import pandas as pd
db=mysql.connector.connect(host='localhost',username='root',passwo
rd='sawan',database='datacamp')
cursor=db.cursor()
ctr=0
bank=1
while bank==1:
print('+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+--')
print('Press 1 for Online Banking')
print('Press 2 for Registering a new bank account')
print('Press 3 for Deleting your account')
print('Press 4 for checking All Account')
print('Press 5 for Customer Help Services')
print('Press 6 for exit')
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
choice=str(input("Option :- "))
print('*******************************************')
if choice==1:
def welcome_message():
print('\t\t\t>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
print('\t\t\tWELCOME TO BANK OF INDIA\b')
print('\t\t\t>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
def login():
while True:
us=input("Enter your username :- ")
p=int(input("Enter your password :-"))
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
value=(us,p)
query="""select * from customers where username=%s
and password=%s """
cursor.execute(query,value)
data_login=cursor.fetchall()
if len(data_login)!=0:
globals()['ctr']=1
break
else:
print('LOGIN UNSUCCSESSFUL')
print("USERNAME OR PASSWORD IS WRONG")
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
return data_login
def interface():
welcome_message()
b=login()
if globals()['ctr']==1:
i=b[0][0]
name=b[0][2]
print("LOGIN SUCCESSFUL")
print('+++++++++++++++++++++++++++++++++++++
+++++++\n')
c=1
while c==1:
print('Press 1 for depositing money')
print('Press 2 for withdrawing money')
print('Press 3 for doing kyc')
print('Press 4 for checking balance')
print('Press 5 for logging out')
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
ch=int(input("Enter your option :- "))
if ch==1:
money_deposit=int(input('Amount to be
deposited :- '))
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
cursor.execute('update customers set
balance=balance+%s where id=%s',(money_deposit,i))
db.commit()
q='select balance from customers where id=
%s and username=%s'
cursor.execute(q,(i,name))
a=cursor.fetchall()
a=a[0]
for x in a:
print("Updated Balance :- ",x)
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
elif ch==2:
money_withdrawn=int(input('Amount to be
withdrawn :- '))
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
cursor.execute('update customers set
balance=balance-%s where id=%s',(money_withdrawn,i))
db.commit()
q='select balance from customers where id=
%s and username=%s'
cursor.execute(q,(i,name))
a=cursor.fetchall()
a=a[0]
for x in a:
print("Updated Balance :- ",x)
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
elif ch==3:
q='select kyc from customers where id=%s
and username=%s'
cursor.execute(q,(i,name))
a=cursor.fetchall()
a=a[0]
for x in a:
condition=x
if condition=='false':
print('-----------------------------------------')
print('For KYC you need to provide
details from one of these government id')
print('Press 1 for Aadhar Card')
print('Press 2 for Voter Id Card')
print('Press 3 for Pan Card')
print('Press 4 for Driving License')
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
cho=int(input("Enter your choice :- "))
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
if cho==1:
ad=int(input("Aadhar Number :-
"))
cursor.execute('update customers
set kyc="true" where id=%s and username=%s',(i,name))
db.commit()
print("\nKYC Done")
elif cho==2:
vi=int(input("Voter Id Number :-
"))
cursor.execute('update customers
set kyc="true" where id=%s and username=%s',(i,name))
db.commit()
print("\nKYC Done")
elif cho==3:
pc=str(input("Pan Card Number :-
"))
cursor.execute('update customers
set kyc="true" where id=%s and username=%s',(i,name))
db.commit()
print("\nKYC Done")
elif ch==4:
dl=str(input("Driving License
Number :- "))
cursor.execute('update customers
set kyc="true" where id=%s and username=%s',(i,name))
db.commit()
print("\nKYC Done")
else:
print('\nWrong Choice')
else:
print('\nKYC Already Done')
print('____________________________________________')
elif ch==4:
q='select balance from customers where id=
%s and username=%s'
cursor.execute(q,(i,name))
a=cursor.fetchall()
a=a[0]
for x in a:
print("\nBalance :- ",x)
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n')
elif ch==5:
c=0
else:
print("Wrong Option ")
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n')
interface()
elif choice==2:
print('Fill these details to register your account ')
idea=random.randint(1,100)
name=input("Enter your name :- ")
username=input('Enter your username :- ')
pas=int(input('Enter your password :- '))
balance=float(input('Enter your balance :- '))
age=int(input('Enter your age :- '))
gender=input('Enter your gender (M/F) :- ')
acno=random.randint(500000000000,1000000000000)
print('---------------------------------------\n')
kyc='false'
query='insert into customers values(%s,%s,%s,%s,%s,%s,%s,%s,
%s)'
value=(idea,name,username,pas,balance,age,gender,kyc,acno)
cursor.execute(query,value)
db.commit()
elif choice==3:
us=input("Enter your username :- ")
p=int(input("Enter your password :-"))
print('------------------------------------\n')
value=(us,p)
query="select * from customers where username=%s and
password=%s "
cursor.execute(query,value)
data_login=cursor.fetchall()
cursor.execute('delete from customers where id=%s and
username=%s',(data_login[0][0],data_login[0][2]))
db.commit()
print('++++++++\nData deleted Succesful\n-------')
elif choice==4:
def welcome_message():
print('\t\t\t>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
print('\t\t\t\tBANK OF INDIA\b')
print('\t\t\t>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
welcome_message()
i='Select * from customers'
cursor.execute(i)
i=cursor.fetchall()
df = pd.DataFrame(i)
print(df)
elif choice==5:
print('\nContact to your Nearest Branch\nOr Email:-
bankofindia@gmail.com ')
print('==================================================\n\
n')
elif choice==6:
bank=0
print('\nThankyou for using Us')
else:
print('Wrong Option')
print('==========================================')
•