0% found this document useful (0 votes)
8 views22 pages

PROJECT

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

PROJECT

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

INTRODUCTION

The project Bank Management System presented here


represents a pivotal solution in the realm of financial
management, blending the sophistication of MySQL as the
database backend with the dynamic capabilities of Python.
This amalgamation results in a comprehensive system that
caters to both administrative and user functionalities,
streamlining processes related to account management,
feedback collection, and loan tracking.

Evolution of Management Systems


using Python and MySQL Connector: The
evolution of management systems, especially in the
banking sector, has witnessed a paradigm shift with the
advent of powerful programming languages like Python
and robust database management systems such as
MySQL. Python, recognized for its simplicity, readability,
and versatility, serves as the ideal frontend language for
developing user-friendly interfaces. MySQL, on the other
hand, provides a reliable and scalable database solution,
ensuring the secure storage and retrieval of crucial
banking information. The integration of these technologies
facilitates a seamless flow of data, enabling real-time
interactions between users and the banking system.
The dynamic connectivity offered by the MySQL Python
Connector ensures efficient communication between the
Python application and the MySQL database.

Purpose of the Bank Management


System: The Bank Management System project aims
to address several key challenges in traditional banking
operations. By leveraging Python's intuitive programming
features and MySQL's robust data management
capabilities, the system provides an agile and user-centric
platform for both customers and administrators.

1. Account Management
Create Account: Open new accounts with various types
such as savings, current, fixed deposit, etc.
Close Account: Close existing accounts.
Update Account Details: Modify account holder
information.
3. Transactions
Deposit: Add funds to accounts.
Withdraw: Withdraw funds from accounts.
Transfer: Transfer funds between accounts.
Transaction History: Maintain and display a history of all
transactions.
4. User Authentication and Security
Login/Logout: Secure login and logout functionality.
6. Reporting
Account Statements: Generate detailed statements for
account holders.
SQL COMMANDS:

create database LPCBank;

use LPCBank;

create table Users(


UserId int primary key,
UserName varchar(30) not null,
Password varchar(30));

create table Accounts(


AccNumber int primary key,
UserId int references Users(UserId),
Balance int);
create table Transactions(
TranId int primary key,
AccNumber int,
Method varchar(30),
Amount int,
Date date,
Receiver varchar(30));

create table KYC (


UserId int references Users(UserId),
AccNumber int,
UserName varchar(30),
Address varchar(100),
MobileNo bigint,
AddhaarCardNo bigint,
Occupation varchar(30),
MonthlyIncome int,
ReferenceName varchar(30),
ReferenceAddress varchar(100),
ReferenceMobileNo bigint);
PYTHON CODE:
import sys
from texttable import *
import random
import mysql.connector as sql
mysql=sql.connect(host="localhost",user="root",passwd="mysql",database
="LPCBank")
cursor=mysql.cursor()
tableobj=Texttable()

def login():
i=int(input("Enter User ID:"))
n=input("Enter User Name:")
p=input("Enter Password:")
cursor.execute("select * from Users")
data=cursor.fetchall()
if (i,n,p) in data:
print("Login Successful.")
return (i,n,p)
else:
return 0

def register():
cursor.execute("select * from Users")
data=cursor.fetchall()
l=[]
for details in data:
l.append(details[0])
while True:
i=int(input("Enter User ID:"))
if i not in l:
n=input("Enter User Name:")
p=input("Enter Password:")
cursor.execute("insert into Users values({},'{}','{}')".format(i,n,p))
mysql.commit()
print("Registration And Login Successfull.")
return (i,n,p)
else:
print("UserId already exists. Retry!!")

def accCreate(user):
i=user[0]
cursor.execute("select AccNumber from Accounts")
data=cursor.fetchall()
while True:
n=random.randint(10000000,99999999)
if (n,) not in data:
break
print(f"Your Account Number is generated and is {n}")
b=int(input("Enter Initial Balance:"))
print("Enter Neccessay Details For KYC.")
na=input("Enter Account Holder Name:")
a=input("Enter Address:")
m=int(input("Enter Mobile Number:"))
ad=int(input("Enter Addhaar Card Number:"))
o=input("Enter Account Holder's Occupation:")
mo=int(input("Enter Account Holder's Monthly Income:"))
rn=input("Enter Reference's Name:")
ra=input("Enter Reference's Address:")
rm=int(input("Enter Reference's Mobile Number:"))
cursor.execute("insert into Accounts values({},{},{})".format(n,i,b))
mysql.commit()
cursor.execute("insert into KYC values({},{},'{}','{}',{},{},'{}',{},'{}','{}',
{})".format(i,n,na,a,m,ad,o,mo,rn,ra,rm))
mysql.commit()
print("Account Created Successfully.")

def accDelete():
cursor.execute("select AccNumber from Accounts")
data=cursor.fetchall()
for i in range(3,0,-1):
a=int(input("Enter Account Number To Delete:"))
if (a,) not in data and (i-1)!=0:
print("Account Number Invalid!!")
print(f"Check And Re-Enter Correct Account Number You Have {i-1}
Chances Left.")
elif (a,) in data:
print("Account Number Valid.")
break
else:
print("Account Number Invalid!!")
print("Too Many Incorrect Attempt.")
print("Program Ending\t....\t...\t..\t.")
sys.exit()

cursor.execute("delete from KYC where AccNumber={}".format(a))


mysql.commit()
cursor.execute("delete from Accounts where AccNumber={}".format(a))
mysql.commit()

def deposit():
cursor.execute("select AccNumber from Accounts")
data=cursor.fetchall()
for i in range(3,0,-1):
a=int(input("Enter Account Number To Deposit:"))
if (a,) not in data and (i-1)!=0:
print("Account Number Invalid!!")
print(f"Check And Re-Enter Correct Account Number You Have {i-1}
Chances Left.")
elif (a,) in data:
print("Account Number Valid.")
break
else:
print("Account Number Invalid!!")
print("Too Many Incorrect Attempt.")
print("Program Ending\t....\t...\t..\t.")
sys.exit()
d=int(input("Enter Amount To Deposit:"))
cursor.execute("update Accounts set Balance=Balance+{} where
AccNumber={}".format(d,a))
mysql.commit()
print("Deposit Successful.")
transaction(a,"Deposit",d)

def withdraw():
cursor.execute("select AccNumber from Accounts")
data=cursor.fetchall()
for i in range(3,0,-1):
a=int(input("Enter Account Number To Withdraw:"))
if (a,) not in data and (i-1)!=0:
print("Account Number Invalid!!")
print(f"Check And Re-Enter Correct Account Number You Have {i-1}
Chances Left.")
elif (a,) in data:
print("Account Number Valid.")
break
else:
print("Account Number Invalid!!")
print("Too Many Incorrect Attempt.")
print("Program Ending\t....\t...\t..\t.")
sys.exit()
w=int(input("Enter Amount To Withdraw:"))
cursor.execute("update Accounts set Balance=Balance-{} where
AccNumber={}".format(w,a))
mysql.commit()
print("Withdraw Successful.")
transaction(a,"Withdraw",w)

def transfer():
cursor.execute("select AccNumber from Accounts")
data=cursor.fetchall()
for i in range(3,0,-1):
a=int(input("Enter Account Number To Transfer From:"))
if (a,) not in data and (i-1)!=0:
print("Account Number Invalid!!")
print(f"Check And Re-Enter Correct Account Number You Have {i-1}
Chances Left.")
elif (a,) in data:
print("Account Number Valid.")
break
else:
print("Account Number Invalid!!")
print("Too Many Incorrect Attempt.")
print("Program Ending\t....\t...\t..\t.")
sys.exit()
for i in range(3,0,-1):
b=int(input("Enter Account Number To Transfer Into:"))
if (b,) not in data and (i-1)!=0:
print("Account Number Invalid!!")
print(f"Check And Re-Enter Correct Account Number You Have {i-1}
Chances Left.")
elif (b,) in data:
print("Account Number Valid.")
break
else:
print("Account Number Invalid!!")
print("Too Many Incorrect Attempt.")
print("Program Ending\t....\t...\t..\t.")
sys.exit()

t=int(input("Enter Amount To Transfer:"))


cursor.execute("update Accounts set Balance=Balance-{} where
AccNumber={}".format(t,a))
mysql.commit()
cursor.execute("update Accounts set Balance=Balance+{} where
AccNumber={}".format(t,b))
mysql.commit()
print("Transfer Successful.")
transaction(a,"Transfer",t,b)

def transHistory():
cursor.execute("select AccNumber from Accounts")
data=cursor.fetchall()
for i in range(3,0,-1):
a=int(input("Enter Account Number For Transaction History:"))
if (a,) not in data and (i-1)!=0:
print("Account Number Invalid!!")
print(f"Check And Re-Enter Correct Account Number You Have {i-1}
Chances Left.")
elif (a,) in data:
print("Account Number Valid.")
break
else:
print("Account Number Invalid!!")
print("Too Many Incorrect Attempt.")
print("Program Ending\t....\t...\t..\t.")
sys.exit()

cursor.execute("select TranId,Method,Amount,Date,Receiver from


Transactions where AccNumber={}".format(a))
data=cursor.fetchall()

d=[["TranId","Method","Amount","Date","Receiver"]]
for row in data:
d.append(list(row))
tableobj.reset()
tableobj.add_rows(d)
print(tableobj.draw())

def accountStatement():
cursor.execute("select AccNumber from Accounts")
data=cursor.fetchall()
for i in range(3,0,-1):
a=int(input("Enter Account Number For Account Statement:"))
if (a,) not in data and (i-1)!=0:
print("Account Number Invalid!!")
print(f"Check And Re-Enter Correct Account Number You Have {i-1}
Chances Left.")
elif (a,) in data:
print("Account Number Valid.")
break
else:
print("Account Number Invalid!!")
print("Too Many Incorrect Attempt.")
print("Program Ending\t....\t...\t..\t.")
sys.exit()
print("\nGenerating Account Statement\t....\t...\t..\t.\n")
cursor.execute("select TranId,Method,Amount,Date,Receiver from
Transactions where AccNumber={}".format(a))
data=cursor.fetchall()
d=[["TranId","Method","Amount","Date","Receiver"]]
for row in data:
d.append(list(row))
tableobj.reset()
tableobj.add_rows(d)

cursor.execute("select Balance from Accounts where


AccNumber={}".format(a))
data=cursor.fetchall()
for i in data:
b=i[0]

print(f"Account Number:{a}")
print(f"Balance:{b}")
print(f"\n\nTransaction History of Account {a} is as follows:\n")
print(tableobj.draw())

s=f"select
UserName,Address,MobileNo,AddhaarCardNo,Occupation,MonthlyIncome,Ref
erenceName,ReferenceAddress,ReferenceMobileNo from KYC where
AccNumber={a}"
cursor.execute(s)
data=cursor.fetchall()
k=["UserName","Address","MobileNo","AddhaarCardNo","Occupation","Mont
hlyIncome","ReferenceName","ReferenceAddress","ReferenceMobileNo"]
for row in data:
l=list(row)

print(f"\nKYC for the Account Number {a} is as follows:\n")


for i,j in zip(k,l):
print(f"{i}:{j}")

def transaction(AccNumber,Method,Amount,Receiver="Self"):
cursor.execute("select TranId from Transactions")
data=cursor.fetchall()
while True:
t=random.randint(100000,999999)
if (t,) not in data:
break
cursor.execute("insert into Transactions values({},{},'{}',
{},curdate(),'{}')".format(t,AccNumber,Method,Amount,Receiver))
mysql.commit()

print("\t\t\tLPCBank")
print("-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
_-_-_-")
print('''
1.Login
2.Register
3.Exit''')

c=int(input("Enter your choice(1-3):"))


if c==1:
user=login()
if user==0:
print("Credentials not found.")
sys.exit()

elif c==2:
user=register()

elif c==3:
sys.exit()

else:
print("Invalid Choice.")
print("Program Ending\t....\t...\t..\t.")
sys.exit()

while True:
print("""TASKS:
1.Account Creation
2.Account Deletion
3.Deposit
4.Withdraw
5.Transfer
6.Transaction History
7.Account Statement
8.Exit
""")
c=int(input("Enter Choice:"))
if c==1:
accCreate(user)
elif c==2:
accDelete()
elif c==3:
deposit()
elif c==4:
withdraw()
elif c==5:
transfer()
elif c==6:
transHistory()
elif c==7:
accountStatement()
elif c==8:
print("Program Ending\t....\t...\t..\t.")
sys.exit()
else:
print("Invalid Choice.")
print("Program Ending\t....\t...\t..\t.")
sys.exit()
OUTPUT:

Account Creation:

Login :
Account Creation:

Deposit:
Withdraw:
Transfer:

Transaction History:
Account Statement:

You might also like