Python Project on Banking Management System

Banking Management System

📜 CERTIFICATE

This is to certify that xyz, a student of Class XII of ________________ School, has successfully completed the Computer Science project titled: “BANKING MANAGEMENT SYSTEM” during the academic session 2025–2026, in partial fulfillment of the requirements for the CBSE Class XII Computer Science (083) curriculum.
This project has been carried out under my guidance and supervision. The work presented is original and has not been copied from any other source.

I wish him all the best for her future endeavors.

Teacher’s Signature: _______________________
Name of Teacher: _________________________
Subject: Computer Science
School Seal: _____________________________

School Name: _____________________________
Date: ___________________

🙏 ACKNOWLEDGEMENT

ACKNOWLEDGEMENT

I would like to express my sincere gratitude to my Computer Science teacher for her valuable guidance, constant encouragement, and support throughout the completion of this project.
I am also thankful to the school authorities for providing the necessary facilities and resources required to complete this project successfully.
I would like to thank my parents and friends for their cooperation, motivation, and moral support during the project work.

Name: abc
Class: XII
Subject: Computer Science
Session: 2025–2026

1. Introduction

The Banking Management System is a Python–MySQL based console application.
This project automates basic banking operations such as account creation, deposits, withdrawals, customer management, and transaction history using simple Python programming concepts and MySQL as the backend database.

The system helps understand real-world database applications and demonstrates how Python can be used to interact with databases efficiently.


2. Objectives

  • To develop a menu-driven banking application
  • To store and manage customer records using MySQL
  • To perform deposit and withdrawal transactions
  • To maintain transaction history
  • To learn Python–MySQL connectivity
  • To generate backup of transactions using pickle

3. Tools & Technologies Used

ComponentDescription
Programming LanguagePython
DatabaseMySQL
Module Usedmysql-connector-python
Additional Moduletabulate, pickle, datetime
PlatformWindows / Linux
InterfaceCommand Line

4. Database Design

Customer Table

Field NameData TypeDescription
accountnoVARCHAR(12)Primary Key
nameVARCHAR(50)Customer Name
ageVARCHAR(3)Age
genderVARCHAR(10)Gender
phoneVARCHAR(10)Phone Number
addharnoVARCHAR(12)Aadhaar Number
opening_balanceFLOATCurrent Balance

Transactions Table

Field NameData Type
tr_idINT (Auto Increment)
accountnoVARCHAR(12)
nameVARCHAR(50)
credit_amountFLOAT
debit_amountFLOAT
tdateDATE
balanceFLOAT

5. Features of the System

  • Account registration
  • Display all customers
  • Search customer by account number
  • Modify customer details
  • Delete customer records
  • Deposit and withdraw money
  • View transaction statement
  • Backup transactions using pickle
  • Proper database connectivity handling

6. Source Code:

📁 banking_management_DB.py

(Database & Table Creation File)

import mysql.connector as sqlcon

try:
    con = sqlcon.connect(
        host="localhost",
        user="root"
        # password="root"   # Uncomment if password exists
    )

    if con.is_connected():
        print("✔ MySQL connection successful")

    cur = con.cursor()

    # Create database
    cur.execute("CREATE DATABASE IF NOT EXISTS banking")
    cur.execute("USE banking")

    # Create customer table
    cur.execute("""
        CREATE TABLE IF NOT EXISTS customer (
            accountno VARCHAR(12) PRIMARY KEY,
            name VARCHAR(50),
            age VARCHAR(3),
            gender VARCHAR(10),
            phone VARCHAR(10),
            addharno VARCHAR(12),
            opening_balance FLOAT
        )
    """)

    # Create transactions table
    cur.execute("""
        CREATE TABLE IF NOT EXISTS transactions (
            tr_id INT AUTO_INCREMENT PRIMARY KEY,
            accountno VARCHAR(12),
            name VARCHAR(50),
            credit_amount FLOAT DEFAULT 0,
            debit_amount FLOAT DEFAULT 0,
            tdate DATE,
            balance FLOAT
        )
    """)

    print("✔ Database and tables created successfully")

except sqlcon.Error as err:
    print("❌ Error:", err)

finally:
    if 'con' in locals() and con.is_connected():
        con.close()
        print("✔ MySQL connection closed")

banking_management_class_12th.py

(Main Banking Program)

import mysql.connector as sqlcon
import datetime
import pickle
from tabulate import tabulate

# Database connection
con = sqlcon.connect(
    host="localhost",
    user="root",
    database="banking"
)
cur = con.cursor()

# ---------------- REGISTER ----------------
def register():
    dt = datetime.date.today()
    cur.execute("SELECT accountno FROM customer")
    data = cur.fetchall()

    # Convert tuple list to a simple list of account numbers
    ac_list = []
    for row in data:
        ac_list.append(str(row[0]))
    

    accountno = input("Enter account number: ")

    if accountno in ac_list:
        print("Account number already exist.")
        return
    else:        
        name = input("Enter name: ")
        age = input("Enter age: ")
        gender = input("Enter gender: ")
        phone = input("Enter phone number: ")
        addharno = input("Enter Aadhaar number: ")
        op_bal = float(input("Enter opening balance: "))

        cur.execute(
            "INSERT INTO customer VALUES (%s,%s,%s,%s,%s,%s,%s)",
            (accountno, name, age, gender, phone, addharno, op_bal)
        )

        cur.execute(
            "INSERT INTO transactions (accountno,name,credit_amount,debit_amount,tdate,balance) "
            "VALUES (%s,%s,%s,%s,%s,%s)",
            (accountno, name, op_bal, 0, dt, op_bal)
        )

        con.commit()
        print("✔ Account registered successfully")

# ---------------- DEPOSIT ----------------
def trans_cr():
    dt = datetime.date.today()
    accountno = input("Enter account number: ")

    cur.execute(
        "SELECT opening_balance, name FROM customer WHERE accountno=%s",
        (accountno,)
    )
    data = cur.fetchone()

    if data:
        bal, name = data
        print("Name:", name)
        print("Balance:", bal)

        amt = float(input("Enter deposit amount: "))
        newbal = bal + amt

        cur.execute(
            "UPDATE customer SET opening_balance=%s WHERE accountno=%s",
            (newbal, accountno)
        )

        cur.execute(
            "INSERT INTO transactions (accountno,name,credit_amount,debit_amount,tdate,balance) "
            "VALUES (%s,%s,%s,%s,%s,%s)",
            (accountno, name, amt, 0, dt, newbal)
        )

        con.commit()
        print("✔ Amount deposited")
    else:
        print("❌ Account not found")

# ---------------- WITHDRAW ----------------
def trans_dbt():
    dt = datetime.date.today()
    accountno = input("Enter account number: ")

    cur.execute(
        "SELECT opening_balance, name FROM customer WHERE accountno=%s",
        (accountno,)
    )
    data = cur.fetchone()

    if data:
        bal, name = data
        print("Name:", name)
        print("Balance:", bal)

        amt = float(input("Enter withdrawal amount: "))

        if amt <= bal:
            newbal = bal - amt

            cur.execute(
                "UPDATE customer SET opening_balance=%s WHERE accountno=%s",
                (newbal, accountno)
            )

            cur.execute(
                "INSERT INTO transactions (accountno,name,credit_amount,debit_amount,tdate,balance) "
                "VALUES (%s,%s,%s,%s,%s,%s)",
                (accountno, name, 0, amt, dt, newbal)
            )

            con.commit()
            print("✔ Amount withdrawn")
        else:
            print("❌ Insufficient balance")
    else:
        print("❌ Account not found")

# ---------------- TRANSACTION DETAILS ----------------
def trans_detail():
    ac = input("Enter account number: ")
    cur.execute("SELECT * FROM transactions WHERE accountno=%s", (ac,))
    data = cur.fetchall()

    if data:
        headers = ["TR_ID", "AC_NO", "NAME", "CREDIT", "DEBIT", "DATE", "BAL"]
        print(tabulate(data, headers=headers, tablefmt="grid"))
    else:
        print("No transactions found")

# ---------------- BACKUP TRANSACTIONS ----------------
def back_up_transactions():
    cur.execute("SELECT * FROM transactions")
    data = cur.fetchall()

    if not data:
        print("No transactions found")
        return

    with open("transaction_backup.bk", "ab") as f:
        for row in data:
            record = {
                "accountno": row[1],
                "name": row[2],
                "credit": row[3],
                "debit": row[4],
                "date": row[5],
                "balance": row[6]
            }
            pickle.dump(record, f)

    headers = ["TR_ID", "AC_NO", "NAME", "CREDIT", "DEBIT", "DATE", "BAL"]
    print(tabulate(data, headers=headers, tablefmt="grid"))
    print("✔ Transaction backup created successfully")

# ---------------- SHOW CUSTOMERS ----------------
def show():
    cur.execute("SELECT * FROM customer")
    data = cur.fetchall()

    if data:
        headers = ["AC_NO", "NAME", "AGE", "GENDER", "PHONE", "AADHAAR", "BAL"]
        print(tabulate(data, headers=headers, tablefmt="grid"))
    else:
        print("No records found")

# ---------------- SEARCH ----------------
def search():
    accountno = input("Enter account number: ")
    cur.execute("SELECT * FROM customer WHERE accountno=%s", (accountno,))
    data = cur.fetchone()

    if data:
        headers = ["AC_NO", "NAME", "AGE", "GENDER", "PHONE", "AADHAAR", "BAL"]
        print(tabulate([data], headers=headers, tablefmt="grid"))
    else:
        print("❌ Record not found")

# ---------------- DELETE ----------------
def delete():
    accountno = input("Enter account number: ")

    cur.execute("SELECT * FROM customer WHERE accountno=%s", (accountno,))
    data = cur.fetchone()

    if data:
        headers = ["AC_NO", "NAME", "AGE", "GENDER", "PHONE", "AADHAAR", "BAL"]
        print(tabulate([data], headers=headers, tablefmt="grid"))
        ch = input("Delete this record? (y/n): ")

        if ch.lower() == 'y':
            cur.execute("DELETE FROM transactions WHERE accountno=%s", (accountno,))
            cur.execute("DELETE FROM customer WHERE accountno=%s", (accountno,))
            con.commit()
            print("✔ Record deleted")
    else:
        print("❌ Record not found")

# ---------------- MODIFY ----------------
def modify():
    accountno = input("Enter account number: ")

    cur.execute("SELECT * FROM customer WHERE accountno=%s", (accountno,))
    data = cur.fetchone()

    if data:
        print("1. Name")
        print("2. Age")
        print("3. Gender")
        print("4. Phone")
        print("5. Aadhaar")

        ch = input("Enter choice: ")

        if ch == '1':
            val = input("Enter new name: ")
            cur.execute("UPDATE customer SET name=%s WHERE accountno=%s", (val, accountno))
        elif ch == '2':
            val = input("Enter new age: ")
            cur.execute("UPDATE customer SET age=%s WHERE accountno=%s", (val, accountno))
        elif ch == '3':
            val = input("Enter new gender: ")
            cur.execute("UPDATE customer SET gender=%s WHERE accountno=%s", (val, accountno))
        elif ch == '4':
            val = input("Enter new phone: ")
            cur.execute("UPDATE customer SET phone=%s WHERE accountno=%s", (val, accountno))
        elif ch == '5':
            val = input("Enter new Aadhaar: ")
            cur.execute("UPDATE customer SET addharno=%s WHERE accountno=%s", (val, accountno))

        con.commit()
        print("✔ Record updated")
    else:
        print("❌ Record not found")

# ---------------- MAIN MENU ----------------
while True:
    print("\n===== Banking Management System =====")
    print("1. Register")
    print("2. Show Customers")
    print("3. Search")
    print("4. Modify")
    print("5. Delete")
    print("6. Transactions")
    print("7. Backup Transactions")
    print("8. Exit")

    ch = input("Enter choice: ")

    if ch == '1':
        register()
    elif ch == '2':
        show()
    elif ch == '3':
        search()
    elif ch == '4':
        modify()
    elif ch == '5':
        delete()
    elif ch == '6':
        print("d - Deposit | w - Withdraw | t - Transaction Statement")
        t = input("Enter choice: ")

        if t == 'd':
            trans_cr()
        elif t == 'w':
            trans_dbt()
        else:
            trans_detail()
    elif ch == '7':
        back_up_transactions()
    else:
        break

con.close()
print("✔ Program closed")

Hardware and Software Requirements

Hardware Requirements

  • Computer / Laptop
  • Minimum 2 GB RAM
  • Keyboard and Mouse

Software Requirements

  • Windows / Linux Operating System
  • Python 3.x
  • MySQL Server
  • mysql-connector-python module

Download

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top