📘 STUDENT MANAGEMENT SYSTEM
Class XII – Computer Science Project (Python + MySQL)
Below is a complete, practical-file-ready “Student Management System” Python project, designed strictly at Class XII CBSE level, using simple Python logic, functions, and MySQL connectivity.
Everything is written in an exam-friendly style, with clear comments, menu-driven flow, and easy MySQL structure.
🔹 PROJECT OVERVIEW
This project helps manage student admission and academic records using:
- Python
- MySQL Database
- mysql-connector-python module
🔹 FOLDER STRUCTURE
Student_Management_System/
│
├── student_management.py # Main Python Program
├── school.sql # MySQL Database File
🗄️ PART 1: Database File (student_db.py)
👉 Create a file named student_db.py and copy-paste the following:
Student_DB.py
import mysql.connector as sqlcon
# Step 1: Connect to MySQL Server
con = sqlcon.connect(
host="localhost",
user="root",
#password="root" # change if needed
)
cur = con.cursor()
# Step 2: Create Database if not exists
cur.execute("CREATE DATABASE IF NOT EXISTS school")
cur.execute("USE school")
print("Database 'school' ready.")
# Step 3: Create Admission Table
cur.execute("""
CREATE TABLE IF NOT EXISTS admission (
admission_no INT PRIMARY KEY,
name VARCHAR(50),
mother_name VARCHAR(50),
father_name VARCHAR(50),
DOB DATE,
date_of_admission DATE,
contact_no VARCHAR(15),
address VARCHAR(100)
)
""")
# Step 4: Create Academic Table
cur.execute("""
CREATE TABLE IF NOT EXISTS academic (
admission_no INT,
name VARCHAR(50),
subject1 INT,
subject2 INT,
subject3 INT,
subject4 INT,
subject5 INT,
total_marks INT,
percentage FLOAT,
rank INT,
FOREIGN KEY (admission_no) REFERENCES admission(admission_no)
)
""")
print("Tables created successfully.")
# Step 5: Insert data into admission table ONLY if empty
cur.execute("SELECT COUNT(*) FROM admission")
count = cur.fetchone()[0]
if count == 0:
admission_data = [
(101, 'Aman', 'Sunita', 'Rajesh', '2007-05-12', '2022-04-01', '9876543210', 'Delhi'),
(102, 'Riya', 'Meena', 'Suresh', '2007-08-20', '2022-04-01', '9876543222', 'Mumbai'),
(103, 'Kunal', 'Pooja', 'Amit', '2007-01-15', '2022-04-01', '9876543333', 'Jaipur'),
(104, 'Neha', 'Anita', 'Ramesh', '2007-11-10', '2022-04-01', '9876543444', 'Bhopal'),
(105, 'Arjun', 'Kavita', 'Manoj', '2007-03-25', '2022-04-01', '9876543555', 'Lucknow')
]
cur.executemany("INSERT INTO admission VALUES (%s,%s,%s,%s,%s,%s,%s,%s)", admission_data)
con.commit()
print("Dummy admission records inserted.")
else:
print("Admission table already has data. No insertion done.")
# Step 6: Insert data into academic table ONLY if empty
cur.execute("SELECT COUNT(*) FROM academic")
count = cur.fetchone()[0]
if count == 0:
academic_data = [
(101, 'Aman', 78, 85, 69, 74, 80, 386, 77.2, 3),
(102, 'Riya', 88, 90, 84, 86, 92, 440, 88.0, 1),
(103, 'Kunal', 70, 65, 72, 68, 75, 350, 70.0, 4),
(104, 'Neha', 82, 80, 78, 85, 88, 413, 82.6, 2),
(105, 'Arjun', 60, 58, 65, 62, 67, 312, 62.4, 5)
]
cur.executemany("INSERT INTO academic VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", academic_data)
con.commit()
print("Dummy academic records inserted.")
else:
print("Academic table already has data. No insertion done.")
# Step 7: Close connection
con.close()
print("Database setup completed successfully.")
🐍 PART 2: PYTHON PROGRAM
👉 File Name: student_management.py
# Student Management System
# Class XII CBSE Project
# Uses MySQL and mysql-connector-python
import mysql.connector
from tabulate import tabulate
from datetime import datetime
# ---------------- DATABASE CONNECTION ----------------
def connect_db():
return mysql.connector.connect(
host="localhost",
user="root",
#password="root",
database="School"
)
# ---------------- ADD STUDENT ----------------
def add_student():
db = connect_db()
cur = db.cursor()
print("\n--- Add New Student ---")
adm = int(input("Admission No: "))
cur.execute("SELECT * FROM admission WHERE admission_no=%s", (adm,))
if cur.fetchone():
print("Student already exists!")
else:
name = input("Name: ")
mname = input("Mother Name: ")
fname = input("Father Name: ")
dob = input("DOB (YYYY-MM-DD): ")
doa = input("Date of Admission (YYYY-MM-DD): ")
contact = input("Contact No: ")
address = input("Address: ")
sql = "INSERT INTO admission VALUES (%s,%s,%s,%s,%s,%s,%s,%s)"
cur.execute(sql, (adm, name, mname, fname, dob, doa, contact, address))
db.commit()
print("Student added successfully!")
db.close()
# ---------------- SEARCH STUDENT ----------------
def search_student():
db = connect_db()
cur = db.cursor()
adm = int(input("Enter Admission No: "))
cur.execute("SELECT * FROM admission WHERE admission_no=%s", (adm,))
data = cur.fetchone()
if data:
data = list(data)
data[4] = data[4].strftime("%d-%m-%Y")
data[5] = data[5].strftime("%d-%m-%Y")
print("================================================")
print("Admission no.: ",data[0])
print("Name: ",data[1])
print("Mother name: ",data[2])
print("Father name: ",data[3])
print("DOB: ",data[4])
print("Date of Admission",data[5])
print("Phone: ",data[6])
print("Address",data[7])
print("================================================")
else:
print("❌ Record not found!")
db.close()
# ---------------- MODIFY STUDENT ----------------
def modify_student():
db = connect_db()
cur = db.cursor()
adm = int(input("Enter Admission No: "))
cur.execute("SELECT * FROM admission WHERE admission_no=%s", (adm,))
if cur.fetchone():
print("1.Name\n2.Mother name\n3.Father name\n4.DOB\n5.Contact no")
c=input("Enter choice:")
if c=='1':
new_name = input("Enter new name: ")
cur.execute("UPDATE admission SET name=%s WHERE admission_no=%s",
(new_name, adm))
elif c=='2':
new_name = input("Enter new mother name: ")
cur.execute("UPDATE admission SET mother_name=%s WHERE admission_no=%s",
(new_name, adm))
elif c=='3':
new_name = input("Enter new father name: ")
cur.execute("UPDATE admission SET father_name=%s WHERE admission_no=%s",
(new_name, adm))
elif c=='4':
new_DOB = input("Enter new DOB yyyy-mm-dd: ")
cur.execute("UPDATE admission SET DOB=%s WHERE admission_no=%s",
(new_DOB, adm))
elif c=='5':
new_contact = input("Enter new contact number: ")
cur.execute("UPDATE admission SET contact_no=%s WHERE admission_no=%s",
(new_contact, adm))
db.commit()
print("Record updated successfully!")
else:
print("❌ Record not found!")
db.close()
# ---------------- DELETE STUDENT ----------------
def delete_student():
db = connect_db()
cur = db.cursor()
adm = int(input("Enter Admission No: "))
cur.execute("SELECT * FROM admission WHERE admission_no=%s", (adm,))
if cur.fetchone():
cur.execute("DELETE FROM academic WHERE admission_no=%s", (adm,))
cur.execute("DELETE FROM admission WHERE admission_no=%s", (adm,))
db.commit()
print("Record deleted successfully!")
else:
print("❌ Record not found!")
db.close()
# ---------------- SHOW ALL STUDENTS ----------------
def show_all_students():
db = connect_db()
cur = db.cursor()
cur.execute("SELECT * FROM admission")
records = cur.fetchall()
if records:
formatted = []
for r in records:
r = list(r)
r[4] = r[4].strftime("%d-%m-%Y")
r[5] = r[5].strftime("%d-%m-%Y")
r.pop(5)# remove admission date from output
formatted.append(r)
print(tabulate(formatted,
headers=["Adno", "SName", "Mother", "Father",
"DOB", "Ph", "Address"],
tablefmt="grid"))
else:
print("❌ No student records found!")
db.close()
# ---------------- ENTER MARKS ----------------
def marks():
db = connect_db()
cur = db.cursor()
adm = int(input("Enter Admission No: "))
cur.execute("SELECT * FROM admission WHERE admission_no=%s", (adm,))
data = cur.fetchone()
if data:
name = data[1]
print("Student Name:", name)
s1 = int(input("Subject 1: "))
s2 = int(input("Subject 2: "))
s3 = int(input("Subject 3: "))
s4 = int(input("Subject 4: "))
s5 = int(input("Subject 5: "))
total = s1 + s2 + s3 + s4 + s5
percent = total / 5
if percent >= 85:
rank = 1
elif percent >= 75:
rank = 2
elif percent >= 65:
rank = 3
else:
rank = 4
cur.execute("DELETE FROM academic WHERE admission_no=%s", (adm,))
sql = "INSERT INTO academic VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
cur.execute(sql, (adm, name, s1, s2, s3, s4, s5, total, percent, rank))
db.commit()
print("Marksheet saved successfully!")
else:
print("❌ Record not found!")
db.close()
# ---------------- SHOW MARKSHEET ----------------
def show_marksheet():
db = connect_db()
cur = db.cursor()
adm = int(input("Enter Admission No: "))
cur.execute("SELECT * FROM academic WHERE admission_no=%s", (adm,))
data = cur.fetchone()
if data:
table = [
["Admission No", data[0]],
["Name", data[1]],
["Subject 1", data[2]],
["Subject 2", data[3]],
["Subject 3", data[4]],
["Subject 4", data[5]],
["Subject 5", data[6]],
["Total", data[7]],
["Percentage", data[8]],
["Rank", data[9]]
]
print(tabulate(table, tablefmt="grid"))
else:
print("❌ Marksheet not found!")
db.close()
# ---------------- MAIN MENU ----------------
while True:
print("""
===== STUDENT MANAGEMENT SYSTEM =====
1. Add Student
2. Search Student
3. Modify Student
4. Delete Student
5. Show All Students
6. Enter Marks
7. Show Marksheet
8. Exit
""")
ch = input("Enter choice: ")
if ch == '1':
add_student()
elif ch == '2':
search_student()
elif ch == '3':
modify_student()
elif ch == '4':
delete_student()
elif ch == '5':
show_all_students()
elif ch == '6':
marks()
elif ch == '7':
show_marksheet()
elif ch == '8':
print("Thank you! Program terminated.")
break
else:
print("❌ Invalid choice!")
▶️ HOW TO RUN THE PROJECT
Step 1️⃣ Install MySQL Connector and tabulate module
pip install mysql-connector-python
pip install tabulate
Step 2️⃣ Run student_db.py File to create database
Step 3️⃣ Run Python Program
python student_management.py
📄 CERTIFICATE
This is to certify that xyz, a student of Class XII, has successfully completed the project titled “Student Management System” during the academic session 2025–26 as prescribed by the Central Board of Secondary Education (CBSE).
This project is an original work done by the student under my supervision and guidance.
The project is based on Python programming and MySQL database and fulfills all the requirements of the Class XII Computer Science practical examination.
Teacher’s Signature: ____________
Teacher’s Name: ____________
School Name: ____________
External Examiner: ____________
Date: ____________
📄 ACKNOWLEDGEMENT
I would like to express my sincere gratitude to my Computer Science teacher for her valuable guidance, encouragement, and continuous support throughout the development of this project.
I am also thankful to my school for providing the necessary facilities and resources to complete this project successfully.
Finally, I would like to thank my parents and friends for their constant support and motivation.
Name: XYZ
Class: XII
Subject: Computer Science
Introduction
In the present digital era, computers play an important role in managing and maintaining data efficiently. Schools deal with a large amount of student information such as admission details, personal records, and academic performance. Managing these records manually is time-consuming and prone to errors. The Student Management System is a Python-based project developed to computerize the process of storing and managing student records. This project uses Python as the front-end programming language and MySQL as the back-end database. It provides an easy and efficient way to perform operations like adding new students, searching student details, updating records, deleting records, and generating student report cards. The project is menu-driven and uses user-defined functions, making it simple to understand and operate.
Objective of the Project
The main objectives of this project are:
- To maintain student admission details digitally
- To store academic marks and generate report cards
- To understand Python–MySQL connectivity
- To implement menu-driven programs using functions
- To reduce manual record-keeping errors
Scope of the Project
This project can be used in schools to:
- Maintain student personal details
- Generate student marksheets
- Perform search, update, and delete operations
- Display student records in a readable format
The project can be further enhanced by adding login systems, GUI, or grade calculation.
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
Tools and Technologies Used
- Programming Language: Python
- Database: MySQL
- Connector: mysql-connector-python
- Editor: IDLE / VS Code
Database Design
Database Name: school
Table 1: admission
| Field Name | Description |
|---|---|
| admission_no | Primary Key |
| name | Student Name |
| mother_name | Mother’s Name |
| father_name | Father’s Name |
| DOB | Date of Birth |
| date_of_admission | Admission Date |
| contact_no | Contact Number |
| address | Address |
Table 2: academic
| Field Name | Description |
|---|---|
| admission_no | Foreign Key |
| name | Student Name |
| subject1–subject5 | Marks |
| total_marks | Total |
| percentage | Percentage |
| rank | Rank |
Functional Description
The project includes the following user-defined functions:
add_student()– Adds new student recordssearch_student()– Searches student by admission numbermodify_student()– Updates student detailsdelete_student()– Deletes student recordsshow_all_students()– Displays all studentsmarks()– Generates marksheet and calculates total, percentage, and rank
Methodology
The project follows a menu-driven approach.
The user selects an option from the menu, and the corresponding function is executed.
Python communicates with the MySQL database using SQL queries to perform required operations.
🔄 FLOWCHART
START
↓
Display Menu
↓
User Choice?
↓
Add / Search / Modify / Delete / Show / Exit
↓
Call Respective Function
↓
Perform Database Operation
↓
Return to Menu
↓
Exit?
↓
END
🖥️ SAMPLE OUTPUT
🔹 Main Menu
===== STUDENT MANAGEMENT SYSTEM =====
1. Add Student
2. Search Student
3. Modify Student
4. Delete Student
5. Show All Students
6. Enter Marks
7. Show Marksheet
8. Exit
Enter choice:
🔹 Show All Students
+--------+---------+----------+----------+------------+------------+--------+
| Adno | SName | Mother | Father | DOB | Ph |Address |
+========+=========+==========+==========+============+============+========+
| 101 | Aman | Sunita | Rajesh | 12-05-2007 | 9876543210 | Delhi |
+--------+---------+----------+----------+------------+------------+--------+
| 102 | Riya | Meena | Suresh | 20-08-2007 | 9876543222 | Mumbai |
+--------+---------+----------+----------+------------+------------+--------+
| 103 | Kunal | Pooja | Amit | 15-01-2007 | 9876543333 | Jaipur |
+--------+---------+----------+----------+------------+------------+--------+
| 105 | Rakesh | ps | fc | 08-06-1981 | 1231231235 | Khatima|
+--------+---------+----------+----------+------------+------------+--------+
🔹 Marksheet Output
Enter choice: 7
Enter Admission No: 102
+--------------+-------------+
| Admission No | 102 |
+--------------+-------------+
| Name | Riya Sharma |
+--------------+-------------+
| Subject 1 | 26 |
+--------------+-------------+
| Subject 2 | 63 |
+--------------+-------------+
| Subject 3 | 63 |
+--------------+-------------+
| Subject 4 | 63 |
+--------------+-------------+
| Subject 5 | 65 |
+--------------+-------------+
| Total | 280 |
+--------------+-------------+
| Percentage | 56.0 |
+--------------+-------------+
| Rank | 4 |
+--------------+-------------+