0% found this document useful (0 votes)
59 views

Bankproject Py

This document contains source code for a banking transaction system. It defines procedures for creating a new bank account, depositing and withdrawing money from an existing account, and displaying account details. The code connects to a MySQL database called "bank" which contains tables to store customer accounts and transaction records. It provides a menu for users to select these transaction types and includes input validation and database queries to complete each operation.

Uploaded by

Pratham Tripathi
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)
59 views

Bankproject Py

This document contains source code for a banking transaction system. It defines procedures for creating a new bank account, depositing and withdrawing money from an existing account, and displaying account details. The code connects to a MySQL database called "bank" which contains tables to store customer accounts and transaction records. It provides a menu for users to select these transaction types and includes input validation and database queries to complete each operation.

Uploaded by

Pratham Tripathi
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/ 2

#SOURCE CODE FOR BANKING TRANSACTIONS

print("****BANK TRANSACTION****")
#creating database
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="")
mycursor=mydb.cursor()
mycursor.execute("create database if not exists bank")
mycursor.execute("use bank")
#creating required tables
mycursor.execute("create table if not exists bank_master(acno char(4)
primary key,name varchar(30),city char(20),mobileno char(10),balance
int(6))")
mycursor.execute("create table if not exists banktrans(acno char
(4),amount int(6),dot date ,ttype char(1),foreign key (acno)
references bank_master(acno))")
mydb.commit()
while(True):

print("1=Create account")
print("2=Deposit money")
print("3=Withdraw money")
print("4=Display account")
print("5=Exit")
ch=int(input("Enter your choice:"))

#PROCEDURE FOR CREATING A NEW ACCOUNT OF THE APPLICANT


if(ch==1):
print("All information prompted are mandatory to be filled")
acno=str(input("Enter account number:"))
name=input("Enter name(limit 35 characters):")
city=str(input("Enter city name:"))
mn=str(input("Enter mobile no.:"))
balance=0
mycursor.execute("insert into bank_master
values('"+acno+"','"+name+"','"+city+"','"+mn+"','"+str(balance)+"')")
mydb.commit()
print("Account is successfully created!!!")

#PROCEDURE FOR UPDATIONG DETAILS AFTER THE DEPOSITION OF MONEY BY THE


APPLICANT
elif(ch==2):
acno=str(input("Enter account number:"))
dp=int(input("Enter amount to be deposited:"))
dot=str(input("enter date of transaction:"))
ttype="d"
mycursor.execute("insert into banktrans
values('"+acno+"','"+str(dp)+"','"+dot+"','"+ttype+"')")
mycursor.execute("update bank_master set
balance=balance+'"+str(dp)+"' where acno='"+acno+"'")
mydb.commit()
print("money has been deposited successully!!!")
#PROCEDURE FOR UPDATING THE DETAILS OF ACCOUNT AFTER THE WITHDRAWL OF
MONEY BY THE APPLICANT

elif(ch==3):
acno=str(input("Enter account number:"))
wd=int(input("Enter amount to be withdrawn:"))
dot=str(input("enter date of transaction:"))
ttype="w"
mycursor.execute("insert into banktrans
values('"+acno+"','"+str(wd)+"','"+dot+"','"+ttype+"')")
mycursor.execute("update bank_master set balance=balance-
'"+str(wd)+"' where acno='"+acno+"'")
mydb.commit()

#PROCEDURE FOR DISPLAYING THE ACCOUNT OF THE ACCOUNT HOLDER AFTER


HE/SHE ENTERS HIS/HER ACCOUNT NUMBER
elif(ch==4):
acno=str(input("Enter account number:"))
mycursor.execute("select * from bank_master where
acno='"+acno+"'")
for i in mycursor:
print(i)
else:
break

You might also like