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

Bank Management CS Project Code - Py

This document contains code to create a basic banking system with Python and MySQL. It allows users to create bank accounts, deposit and withdraw money, and view account details. The code first connects to a MySQL database called "bank" and creates tables to store account and transaction data. It then runs a loop displaying a menu where the user can choose to create an account, deposit money, withdraw money, or view an account. Functions are defined to handle each transaction type by inserting and updating the appropriate database records.

Uploaded by

Riddhima Murarka
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Bank Management CS Project Code - Py

This document contains code to create a basic banking system with Python and MySQL. It allows users to create bank accounts, deposit and withdraw money, and view account details. The code first connects to a MySQL database called "bank" and creates tables to store account and transaction data. It then runs a loop displaying a menu where the user can choose to create an account, deposit money, withdraw money, or view an account. Functions are defined to handle each transaction type by inserting and updating the appropriate database records.

Uploaded by

Riddhima Murarka
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

print("****BANK TRANSACTION****")

import mysql.connector

mydb=mysql.connector.connect(host="localhost",user="root", passwd="ssc2019")

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: YYYY-MM-DD "))

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: YYYY-MM-DD "))

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