Class 12 Computer Science Project Report
Project Title: Bank Management System Using Python
and MySQL
Submitted by: [Your Name]
Roll Number: [Your Roll No.]
Class & Section: XII - [Your Section]
School: [Your School Name]
Academic Year: 2025-2026
Subject: Computer Science (Code: 083)
Date of Submission: November 14, 2025
Certificate:-
This is to certify that [Your Name], student of Class XII, [Your
Section], has successfully completed the Computer Science Project
titled Bank Management System Using Python and MySQL under
the guidance of [Teacher's Name], during the academic year 2025-
2026.
This project is a bona fide record of work carried out by the student
and has been found satisfactory.
Internal Examiner [Signature] [Name] [Date]
External Examiner [Signature] [Name] [Date]
Guide/Teacher [Signature] [Name] [Date]
Acknowledgement:-
I would like to express my sincere gratitude to my Chemistry
teacher [Mr. D.K. Sharma] for their continuous guidance,
support, and encouragement throughout this project. Their
expertise and insights have been invaluable in completing
this study.
I am also grateful to our school laboratory staƯ for providing
the necessary equipment and materials needed for
conducting the experiments.
I would like to thank the principal [[Link]] and
school management for providing the facilities and
opportunity to undertake this project work. Finally, I express
my thanks to my parents and friends for their moral support
and encouragement.
Index:-
S. No. Topic Page No.
1 Introduction 1
2 Objectives 2
3 System Analysis 3
4 System Design 4-6
5 Implementation 7-10
6 Testing and Debugging 11-12
7 Conclusion and Future Scope 13
8 Bibliography 14
9 Appendices (Code, Screenshots) 15-20
1. Introduction
1.1 Project Overview
In the modern era of digital banking, efficient management of user
accounts and transactions is crucial for financial institutions. This
project, Bank Management System (BMS), is a console-based
application developed using Python 3.x and MySQL 8.0. It simulates
core banking functionalities such as user registration, login, account
creation, deposits, withdrawals, fund transfers, balance inquiries, and
transaction history viewing.
The system addresses real-world needs by ensuring data persistence
through a relational database, preventing unauthorized access via
basic authentication, and maintaining transaction integrity with
atomic operations. As a Class 12 Computer Science project under
CBSE curriculum, it demonstrates key concepts like object-oriented
programming (OOP), database connectivity, SQL queries, and error
handling.
1.2 Need for the Project
Manual banking processes are error-prone and time-consuming. This
system automates routine tasks, reducing human intervention and
enhancing security. It serves as an educational tool to explore Python-
MySQL integration, aligning with syllabus topics like data structures,
SQL, and application development.
1.3 Tools and Technologies Used
Programming Language: Python 3.12 (with libraries: mysql -
connector-python, date/time)
Database: MySQL 8.0
IDE: PyCharm/IDLE
OS: Windows 11
Other: Git for version control (optional)
2. Objectives:-
2.1 Primary Objectives
To develop a user-friendly interface for banking operations using console
menus.
To implement secure user authentication and multi-account support per
user.
To demonstrate CRUD (Create, Read, Update, Delete) operations on a
MySQL database.
2.2 Secondary Objectives
To ensure transaction atomicity using COMMIT/ROLLBACK
for data consistency.
To incorporate input validation and error handling for robust
performance.
To generate transaction logs with related account tracking for
audit trails.
2.3 Learning Outcomes
Understanding of database normalization and foreign key
relationships.
Practical application of exception handling in Python.
Skills in modular coding for maintainability.
3. System Analysis:-
3.1 Feasibility Study
Technical Feasibility: Python and MySQL are freely available;
no advanced hardware required.
Operational Feasibility: Console-based, easy to deploy on
local machines.
Economic Feasibility: Zero cost beyond existing school lab
resources.
3.2 Requirements
Hardware: PC with 4GB RAM, MySQL Server.
Software: Python 3.x, MySQL Workbench.
Functional Requirements: User management, transaction
processing.
Non-Functional: Secure, scalable for 100+ records.
3.3 Data Flow
Users interact via menus → Input validation → DB Query → Output
display. Errors trigger rollbacks.
4. System Design:-
4.1 Database Design (ER Diagram)
The system uses a relational model with three tables:
Entity-Relationship Diagram (Textual Representation)
+-------------+ +-------------+ +-----------------+
| Users |1 N| Accounts |1 N| Transactions |
+-------------+ +-------------+ +-----------------+
| user_id (PK)|<----- | account_id |<----- | transaction_id |
| username | | user_id (FK)| | account_id (FK) |
| password | | creation_date| | transaction_type|
| full_name | | balance | | amount |
+-------------+ +-------------+ | transaction_date|
| | related_account |
+-----+-----------------+
Normalization: 3NF to avoid redundancy.
Keys: Primary (AUTO_INCREMENT), Foreign (CASCADE DELETE).
SQL Schema:-
CREATE DATABASE IF NOT EXISTS bank;
USE bank;
CREATE TABLE IF NOT EXISTS users (
user_id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
full_name VARCHAR(100) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS accounts (
account_id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
creation_date DATE NOT NULL,
balance DECIMAL(15,2) DEFAULT 0.00,
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS transactions (
transaction_id INT AUTO_INCREMENT PRIMARY KEY,
account_id INT NOT NULL,
transaction_type VARCHAR(20) NOT NULL,
transaction_date TIMESTAMP DEFAULT CURRENT_
amount DECIMAL(15,2) NOT NULL, TIMESTAMP,
related_account INT NULL,
FOREIGN KEY (account_id) REFERENCES accounts(account_id) ON DELETE
CASCADE
);
4.2 Data Flow Diagram (Level 0)
text
[User] --> [Input] --> [Process Menu] --> [DB Operations] --> [Output]
^ | |
| v v
+---------------- [Validation] <--- [Error Handling] <--- [Rollback]
4.3 Algorithm for Key Functions
Deposit: Fetch accounts → Select account → Validate amount > 0 →
UPDATE balance + amount → INSERT DEPOSIT txn → COMMIT.
Transfer: Select sender → Input recipient/amount → Validate balance &
existence → UPDATE sender - amount, recipient + amount → INSERT
TRANSFER_OUT/IN with related_account → COMMIT.
5. Implementation:-
5.1 Code Structure
The code is modular:
[Link]: DB credentials.
[Link]: Validation functions (e.g., get_positive_float).
[Link]: Core logic.
Key Code Snippets
Database Connection:
#python
import [Link]
import datetime
# Database Connection
def get_db_connection():
try:
connection = [Link](
host='localhost',
user='root',
password='passpass123?', # Update with your MySQL root
password
database='bank'
)
return connection
except [Link] as error:
print("Error connecting to MySQL:", err)
return None
User Registration:-
def register_user():
connection = get_db_connection()
if connection is None:
return
cursor = [Link]()
username = input("Enter a username: ").strip()
full_name = input("Enter your full name: ").strip()
password = input("Enter your password: ").strip()
try:
[Link]("SELECT * FROM users WHERE username=
%s", (username,))
if [Link]():
print("Username already exists. Try a different one.")
return
[Link](
"INSERT INTO users (username, password, full_name)
VALUES (%s, %s, %s)",
(username, password, full_name)
)
[Link]()
print("Registration successful! You can now log in.")
except [Link] as err:
print("Error during registration:", err)
finally:
[Link]()
[Link]()
User Login:-
def login_user():
connection = get_db_connection()
if connection is None:
return None
cursor = [Link](dictionary=True)
username = input("Enter your username: ").strip()
password = input("Enter your password: ").strip()
try:
[Link](
"SELECT * FROM users WHERE username=%s AND
password=%s",
(username, password)
)
user = [Link]()
if user:
print(f"Welcome {user['full_name']}!")
return user
else:
print("Login failed. Check your credentials.")
return None
except [Link] as err:
print("Error during login:", err)
return None
finally:
[Link]()
[Link]()
Account Creation:-
def create_account(user_id):
connection = get_db_connection()
if connection is None:
return
cursor = [Link]()
creation_date = [Link]()
try:
[Link](
"INSERT INTO accounts (user_id, creation_date, balance) VALUES
(%s, %s, %s)",
(user_id, creation_date, 0.00)
[Link]()
print("Bank account created successfully!")
except [Link] as err:
print("Error creating account:", err)
finally:
[Link]()
[Link]()
Deposit Function :-
def deposit_amount(user_id):
connection = get_db_connection()
if connection is None:
return
cursor = [Link]()
[Link]("SELECT account_id, balance FROM accounts WHERE user_id=%s",
(user_id,))
accounts = [Link]()
if not accounts:
print("You do not have any bank account.")
[Link]()
[Link]()
return
if len(accounts) > 1:
print("Your Accounts:")
for i, acc in enumerate(accounts):
print(f"{i+1}. Account ID: {acc[0]}, Balance: {acc[1]:.2f}")
try:
choice = int(input("Select account number: ")) - 1
if choice < 0 or choice >= len(accounts):
print("Invalid account selection.")
return
account_id = accounts[choice][0]
except ValueError:
print("Invalid input. Please enter a number.")
return
else:
account_id = accounts[0][0]
try:
amount = float(input("Enter amount to deposit: "))
except ValueError:
print("Invalid amount. Please enter a number.")
return
if amount <= 0:
print("Amount must be positive.")
[Link]()
[Link]()
return
try:
[Link](
"UPDATE accounts SET balance = balance + %s WHERE account_id = %s",
(amount, account_id)
)
Record transaction :-
[Link](
"INSERT INTO transactions (account_id,
transaction_type, amount, transaction_date)
VALUES (%s, 'DEPOSIT', %s, %s)",
(account_id, amount, [Link]())
[Link]()
print(f"Deposited ₹{amount:.2f} to Account ID
{account_id}.")
except [Link] as err:
print("Error during deposit:", err)
finally:
[Link]()
[Link]()
Withdraw:-
def withdraw_amount(user_id):
connection = get_db_connection()
if connection is None:
return
cursor = [Link]()
[Link]("SELECT account_id, balance FROM accounts WHERE user_id=%s",
(user_id,))
accounts = [Link]()
if not accounts:
print("You do not have any bank account.")
[Link]()
[Link]()
return
if len(accounts) > 1:
print("Your Accounts:")
for i, acc in enumerate(accounts):
print(f"{i+1}. Account ID: {acc[0]}, Balance: {acc[1]:.2f}")
try:
choice = int(input("Select account number: ")) - 1
if choice < 0 or choice >= len(accounts):
print("Invalid account selection.")
return
account_id, account_balance = accounts[choice]
except ValueError:
print("Invalid input. Please enter a number.")
return
else:
account_id, account_balance = accounts[0]
try:
amount = float(input("Enter amount to withdraw: "))
except ValueError:
print("Invalid amount. Please enter a number.")
return
if amount <= 0:
print("Amount must be positive.")
[Link]()
[Link]()
return
if amount > account_balance:
print("Insufficient balance.")
[Link]()
[Link]()
return
try:
[Link]"UPDATE accounts SET balance = balance - %s WHERE account_id =
%s",
(amount, account_id))
Record transaction:-- ADDED THIS
[Link](
"INSERT INTO transactions (account_id, transaction_type, amount,
transaction_date) VALUES (%s, 'WITHDRAWAL', %s, %s)",
(account_id, amount, [Link]())
[Link]()
print(f"Withdrew ₹{amount:.2f} from Account ID {account_id}.")
except [Link] as err:
print("Error during withdrawal:", err)
finally:
[Link]()
[Link]()Transfer Function (Enhanced):
Balance inquiry:-
def display_balance(user_id):
connection = get_db_connection()
if connection is None:
return
cursor = [Link]()
try:
[Link]("SELECT account_id, balance FROM accounts WHERE user_id=%s",
(user_id,))
accounts = [Link]()
if not accounts:
print("No accounts found for you.")
else:
for acc in accounts:
print(f"Account ID: {acc[0]}, Balance: ₹{acc[1]:.2f}")
except [Link] as err:
print("Error fetching balance:", err)
finally:
[Link]()
[Link]()
Transfer:-
def transfer_amount(user_id):
connection = get_db_connection()
if connection is None:
return
cursor = [Link]()
try:
[Link]("SELECT account_id, balance FROM accounts WHERE user_id=%s",
(user_id,))
sender_accounts = [Link]()
if not sender_accounts:
print("You do not have any bank account.")
return
if len(sender_accounts) > 1:
print("Your Accounts:")
for i, acc in enumerate(sender_accounts):
print(f"{i+1}. Account ID: {acc[0]}, Balance: ₹{acc[1]:.2f}")
try:
choice = int(input("Select sender account number: ")) - 1
if choice < 0 or choice >= len(sender_accounts):
print("Invalid account selection.")
return
sender_id, sender_balance = sender_accounts[choice]
except ValueError:
print("Invalid input. Please enter a number.")
return
else:
sender_id, sender_balance = sender_accounts[0]
try:
recipient_id = int(input("Enter recipient Account ID: "))
amount = float(input("Enter amount to transfer: "))
except ValueError:
print("Invalid input. Please enter numbers.")
return
if amount <= 0:
print("Amount must be positive.")
return
if amount > sender_balance:
print("Insufficient balance.")
return
[Link]("SELECT account_id, user_id FROM accounts WHERE account_id=
%s", (recipient_id,))
recipient_account = [Link]()
if not recipient_account:
print("Recipient account does not exist.")
return
Prevent self-transfer:-
if recipient_account[0] == sender_id:
print("Cannot transfer to the same account.")
return
[Link]("UPDATE accounts SET balance = balance - %s WHERE account_id =
%s", (amount, sender_id))
[Link]("UPDATE accounts SET balance = balance + %s WHERE account_id =
%s", (amount, recipient_id))
Record transactions for both accounts:-
[Link](
"INSERT INTO transactions (account_id, transaction_type, amount, transaction_date,
related_account) VALUES (%s, 'TRANSFER_OUT', %s, %s, %s)",
(sender_id, amount, [Link](), recipient_id)
[Link](
"INSERT INTO transactions (account_id, transaction_type, amount, transaction_date,
related_account) VALUES (%s, 'TRANSFER_IN', %s, %s, %s)",
(recipient_id, amount, [Link](), sender_id))
[Link]()
print(f"Transferred ₹{amount:.2f} from Account ID {sender_id} to Account ID
{recipient_id}.")
except [Link] as err:
print("Error during transfer:", err)
finally:
[Link]()
[Link]()
View Transaction History:-
def view_transaction_history(user_id):
connection = get_db_connection()
if connection is None:
return
cursor = [Link](dictionary=True)
try:
[Link]("SELECT account_id FROM accounts WHERE user_id=%s", (user_id,))
accounts = [Link]()
if not accounts:
print("No accounts found.")
return
account_ids = [acc['account_id'] for acc in accounts]
if len(account_ids) > 1:
print("Your Accounts:")
for i, acc in enumerate(accounts):
print(f"{i+1}. Account ID: {acc['account_id']}")
try:
choice = int(input("Select account number to view transactions: ")) - 1
if choice < 0 or choice >= len(accounts):
print("Invalid account selection.")
return
selected_account_id = accounts[choice]['account_id']
except ValueError:
print("Invalid input. Please enter a number.")
return
else:
selected_account_id = accounts[0]['account_id']
[Link]("""
SELECT transaction_type, amount, transaction_date, related_account
FROM transactions
WHERE account_id = %s
ORDER BY transaction_date DESC
LIMIT 10
""", (selected_account_id,))
transactions = [Link]()
if not transactions:
print("No transactions found for this account.")
else:
print(f"\nLast 10 transactions for Account ID {selected_account_id}:")
print("-" * 60)
for trans in transactions:
related_acc = f" (to/from Account {trans['related_account']})" if
trans['related_account'] else ""
print(f"{trans['transaction_type']}: ₹{trans['amount']:.2f} on
{trans['transaction_date']}{related_acc}")
except [Link] as err:
print("Error fetching transaction history:", err)
finally:
[Link]()
[Link]()
Main Menu:-
def main():
while True:
print("\nWelcome to the Bank Management System")
print("1. Register")
print("2. Login")
print("3. Exit")
choice = input("Enter your choice: ")
if choice == '1':
register_user()
elif choice == '2':
user = login_user()
if user:
while True:
print("\nAccount Operations Menu")
print("1. Create Account")
print("2. Deposit")
print("3. Withdraw")
print("4. Balance Inquiry")
print("5. Transfer Money")
print("6. View Transaction History")
print("7. Logout")
inner_choice = input("Enter your choice: ")
if inner_choice == '1':
create_account(user['user_id'])
elif inner_choice == '2':
deposit_amount(user['user_id'])
elif inner_choice == '3':
withdraw_amount(user['user_id'])
elif inner_choice == '4':
display_balance(user['user_id'])
elif inner_choice == '5':
transfer_amount(user['user_id'])
elif inner_choice == '6':
view_transaction_history(user['user_id'])
elif inner_choice == '7':
print("Logged out.\n")
break
else:
print("Invalid choice. Try again.")
elif choice == '3':
print("Thank you for using the Bank Management System.")
break
else:
print("Invalid choice. Please select from the menu.")
if __name__ == "__main__":
main()
5.2 Input Validation:-
Loops for positive amounts and valid choices using [Link].
Parameterized queries prevent SQL injection.
5.3 Output Format:-
Balances in ₹ with 2 decimals.
History: "DEPOSIT: ₹100.00 on 2025-11-14 10:30:00"
6. Testing and Debugging:-
6.1 Test Cases:-
Test Description Input Expected Actual Status
Case Output Output
ID
TC01 User New "Registration Matches Pass
Registration username/password successful!"
TC02 Duplicate Existing username "Username Matches Pass
Username already exists."
TC03 Deposit Positive Amount: 500 Balance updated; Matches Pass
Amount Txn logged
TC04 Withdraw Amount: 1000 "Insufficient Matches Pass
Insufficient (Balance: 500) balance."
Funds
TC05 Transfer to Self Recipient ID: Same as "Cannot transfer Matches Pass
sender to same."
TC06 View History Select account Last 10 txns with Matches Pass
related_acc
6.2 Debugging Techniques
Used print statements for variable tracing.
MySQL logs for query errors.
Fixed issues: Resource leaks (added finally blocks), invalid inputs
(validation loops).
6.3 Limitations Encountered
Console UI lacks visuals; no multi-user concurrency.
7. Conclusion and Future Scope
7.1 Conclusion
The Bank Management System successfully integrates Python with MySQL to
deliver a functional banking prototype. It fulfills CBSE Class 12 objectives by
showcasing database operations, OOP modularity, and secure coding practices.
The project enhances understanding of real-time applications and prepares for
advanced topics like web development.
7.2 Future Scope:-
Security: Implement password hashing (bcrypt) and JWT sessions.
UI Enhancement: GUI with Tkinter or web app via Flask.
Features: Add interest calculation, email alerts, admin panel for reports.
Scalability: Cloud deployment (AWS RDS) and multi-threading.
This project marks a milestone in my CS journey, blending theory with practical innovation.
8. Bibliography
1. Python Documentation: [Link]
2. MySQL 8.0 Reference Manual: [Link]
3. CBSE Class 12 Computer Science Syllabus (2025-26):
[Link]
4. GeeksforGeeks: "Python MySQL Tutorial" (Accessed: Nov 2025)
5. Book: "Computer Science with Python" by Sumita Arora (Dhanpat Rai &
Co.)