0% found this document useful (0 votes)
12 views21 pages

CS Project Pages

The document is a project report for a Student Management System created by Swapnil Agrahari for AISSCE 2025 at Indorama Public School. It outlines the project's objectives, specifications, source code, and includes acknowledgments and declarations. The system allows for managing student data, including adding, viewing, and deleting records, as well as recording attendance and marks, using Python and MySQL.

Uploaded by

Swapnil
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)
12 views21 pages

CS Project Pages

The document is a project report for a Student Management System created by Swapnil Agrahari for AISSCE 2025 at Indorama Public School. It outlines the project's objectives, specifications, source code, and includes acknowledgments and declarations. The system allows for managing student data, including adding, viewing, and deleting records, as well as recording attendance and marks, using Python and MySQL.

Uploaded by

Swapnil
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/ 21

INDORAMA PUBLIC SCHOOL

JAGDISHPUR

AISSCE 2025

COMPUTER SCIENCE PROJECT:


STUDENT MANAGEMENT SYSTEM
Submitted by: Swapnil Agrahari
Roll No. :
PARTICULARS

Project Title - Student Management System


Enrollment Number:
Name: Swapnil Agrahari
Class: - XII
School Name – Indorama Public School,
Jagdishpur
Session: 2024-25

Teacher's Remark -

External Examiner's Internal Examiner's


Signature Signature
INDEX
S.N CONTENT PG NO.
1 AKNOWLEDGEMENT 1
2 DECLARATION 2
3 CERTIFICATE 3
4 SYNOPSIS 4
5 PROJECT SPECIFICATIONS 5-6
6 SOURCE CODE 7-14
7 OUTPUT 15-16
8 BIBLIOGRAPHY 17
ACKNOWLEDGEMENT
I have taken efforts in this project. However, it
would not have been possible without the kind
support and help of many individuals and
organizations.
I would like to extend my sincere thanks to my
school and the Principal, Mr. Snehashish Mukherjee,
for
providing me with facilities required to do my
project.
l am highly indebted to my Computer Science
teacher, Mr. Mani Bhushan, for his invaluable
guidance which has sustained my efforts in all stages
Of this project work.
I would also like to thank my parents for their
Continuous, support and encouragement. My thanks
and appreciations also go to my fellow classmates
and to people who have willingly helped me out
with their abilities.
Thanking you,
Swapnil Agrahari
1
DECLARATION
I, Swapnil Agrahari
Roll no.
Declare that this project report entitled ‘Hospital
Management System' is being Submitted to The
Indorama Public School, Jagdishpur in partial
fulfillment of
AISSCE 2025.
This project is never submitted to any other
Institution or board and is the outcome of my
own efforts.

Swapnil Agrahari ROLL NUMBER:

2
CERTIFICATE
This is to certify that the project report entitled,
Student Management System
is being
submitted to
Indorama Public School
Jagdishpur
in partial fulfillment of
AISSCE 2025
This is the original work carried out by our
Bonafide student,
Swapnil Agrahari
under my
guidance. The content embodied in this project
is
the genuine work done by the student.

Mr. Mani Bhushan


(PGT COMPUTER SCIENCE)

3
SYNOPSIS
Project Title: Student Management System

Objective:
This code implements a console-based Student
Management System in Python to manage student data in a
MySQL database. It connects to the database, allowing an
admin to add, view, or delete student records, record
attendance, and assign marks. Students can log in to view
their attendance and marks. The system authenticates users
as either admins or students and provides role-based
permissions for different operations. It includes methods for
database connectivity, input validation, and safe connection
closure. The interface is menu-driven, allowing users to
interact with the system through simple prompts and
commands.

Tools used: Python 3-7.3(32-bit), My SQL 5.0

Platform used: MS Windows 8 and above.

Hardware used: Intel Pentium 4 and above.

4
PROJECT SPECIFICATIONS
Function Description:

__init__ Initializes the Student Management System instance, setting


up database connection and user role variables.
create_connection Establishes a connection to the MySQL database.
check_connection Checks if the database connection is active; attempts to
reconnect if it’s not
authenticate_user Authenticates the user as either an admin or a student and sets
the role accordingly.
add_student Adds a new student to the database (admin only).
view_students Retrieves and displays all students from the database.
delete_student Deletes a student from the database by student ID (admin
only).
record_attendance Records attendance for a student.
view_attendance Displays attendance records for the logged-in student.
add_marks Adds marks for a specific student.
view_marks Displays marks for the logged-in student.
close_connection Closes the database connection.

5
DATABASE USED:- student_management

Tables used:
Students:

Attendance:

Marks:

6
SOURCE CODE

7
import mysql.connector
from mysql.connector import Error
from datetime import date

class StudentManagementSystem:
def __init__(self):
# Initialize the database connection and user role
self.connection = self.create_connection()
self.current_user_role = None
self.current_student_id = None # Store the logged-in student ID

def create_connection(self):
# Create a connection to the MySQL database
try:
connection = mysql.connector.connect(
host='localhost',
user='root',
password='tiger',
database='student_management'
)
if connection.is_connected():
#print("Connected to the database.")
return connection
except Error as e:
print(f"Error: {e}")
return None

def check_connection(self):
# Check if the database connection is active; if not, attempt to reconnect
if self.connection is None or not self.connection.is_connected():
print("No connection to the database. Attempting to reconnect...")
self.connection = self.create_connection()
if self.connection is None:
print("Failed to reconnect to the database. Please try again later.")
return False
return True

def authenticate_user(self):
# User authentication method for admin and students
try:
while True:
print("\n--- User Authentication ---")
print("1. Admin Login")
print("2. Student Login")
print("3. Exit")
choice = input("Choose your role: ")

if choice == '1':
username = input("Enter admin username: ")
password = input("Enter admin password: ")
if username == "admin" and password == "admin123": # Simple authentication
self.current_user_role = "admin"
print("Admin logged in.") 8
return True
else:
print("Invalid admin credentials.")

elif choice == '2':


self.current_student_id = input("Enter your student ID: ")
self.current_user_role = "student"
print(f"Student {self.current_student_id} logged in.")
return True

elif choice == '3':


print("Exiting...")
return False

else:
print("Invalid choice.")
except Exception as e:
print(f"Error during authentication: {e}")

def add_student(self, student_id, name, fname, dob, major, roll_no, class_code, pno, email):
if self.current_user_role != "admin":
print("Permission denied: Only admins can add students.")
return
if not self.check_connection():
return

try:
with self.connection.cursor() as cursor:
query = "INSERT INTO students (id, name, father_name, dob, major, roll_no, class_code, phone_no, email) VALUES (%s, %s, %s, %s,
%s, %s, %s, %s, %s)"
cursor.execute(query, (student_id, name, fname, dob, major, roll_no, class_code, pno, email))
self.connection.commit()
print(f"Student {name} added successfully.")
except Error as e:
print(f"Failed to add student: {e}")

def view_students(self):
if not self.check_connection():
return

try:
with self.connection.cursor() as cursor:
query = "SELECT * FROM students"
cursor.execute(query)
rows = cursor.fetchall()
if rows:
print("\n--- Students List ---")
for row in rows:
print(row)
else:
print("No student records found.")
except Error as e:
print(f"Failed to retrieve students: {e}") 9

def delete_student(self, student_id):


if self.current_user_role != "admin":
print("Permission denied: Only admins can delete students.")
return
if not self.check_connection():
return
try:
with self.connection.cursor() as cursor:
query = "DELETE FROM students WHERE id = %s"
cursor.execute(query, (student_id,))
self.connection.commit()
if cursor.rowcount == 0:
print(f"No student found with ID {student_id}.")
else:
print(f"Student with ID {student_id} deleted successfully.")
except Error as e:
print(f"Failed to delete student: {e}")

def record_attendance(self, student_id, status, late_arrival):


if status not in ["Present", "Absent"]:
print("Invalid status. Please enter 'Present' or 'Absent'.")
return

if not self.check_connection():
return

try:
with self.connection.cursor() as cursor:
query = "INSERT INTO attendance (student_id, date, status, late_arrival) VALUES (%s, %s, %s ,%s)"
cursor.execute(query, (student_id, date.today(), status, late_arrival))
self.connection.commit()
print(f"Attendance recorded for student ID {student_id}: {status}.")
except Error as e:
print(f"Failed to record attendance: {e}")

def view_attendance(self):
if not self.check_connection():
return

try:
with self.connection.cursor() as cursor:
query = "SELECT * FROM attendance WHERE student_id = %s"
cursor.execute(query, (self.current_student_id,))
rows = cursor.fetchall()
if rows:
print(f"\n--- Attendance for Student ID {self.current_student_id} ---")
for row in rows:
print(row)
else:
print("No attendance records found.")
except Error as e: 10
print(f"Failed to retrieve attendance: {e}")

def add_marks(self, student_id, subject, score, roll_no, class_code):


if score < 0:
print("Score must be a non-negative integer.")
return

if not self.check_connection():
return

try:
with self.connection.cursor() as cursor:
query = "INSERT INTO marks (student_id, roll_no, class_code, subject, score) VALUES (%s, %s, %s, %s, %s)"
cursor.execute(query, (student_id, roll_no, class_code, subject, score))
self.connection.commit()
print(f"Marks added for student ID {student_id} in {subject}.")
except Error as e:
print(f"Failed to add marks: {e}")

def view_marks(self):
if not self.check_connection():
return

try:
with self.connection.cursor() as cursor:
query = "SELECT * FROM marks WHERE student_id = %s"
cursor.execute(query, (self.current_student_id,))
rows = cursor.fetchall()
if rows:
print(f"\n--- Marks for Student ID {self.current_student_id} ---")
for row in rows:
print(row)
else:
print("No marks records found.")
except Error as e:
print(f"Failed to retrieve marks: {e}")

def close_connection(self):
try:
if self.connection is not None and self.connection.is_connected():
self.connection.close()
print("MySQL connection is closed.")
except Error as e:
print(f"Error closing the connection: {e}")

if __name__ == "__main__":
sms = StudentManagementSystem()

while True:
if not sms.authenticate_user():
break # Exit the loop if authentication fails or user chooses to exit

while True: 11
if sms.current_user_role == "admin":
print("\n--- Admin Menu ---")
print("1. Add Student")
print("2. View Students")
print("3. Delete Student")
print("4. Record Attendance")
print("5. View Attendance")
print("6. Add Marks")
print("7. View Marks")
print("8. Exit")

choice = input("Enter your choice: ")

if choice == '1':
student_id = int(input("Enter student ID: "))
name = input("Enter student name: ")
fname = input("Enter father's name: ")
dob = input("Enter student's dob (YYYY-MM-DD): ")
major = input("Enter student major: ")
roll_no = input("Enter student roll number: ")
class_code = input("Enter student class: ")
pno = int(input("Enter Phone number: "))
email = input("Enter email: ")
sms.add_student(student_id, name, fname, dob, major, roll_no, class_code, pno, email)
elif choice == '2':
sms.view_students() # View all students
elif choice == '3':
student_id = int(input("Enter student ID to delete: "))
sms.delete_student(student_id) # Delete a student
elif choice == '4':
student_id = int(input("Enter student ID for attendance: "))
status = input("Enter status (Present/Absent): ")
late_arrival = input("Is student arriving late? (Yes/No): ")
sms.record_attendance(student_id, status, late_arrival) # Record attendance
elif choice == '5':
sms.view_attendance() # View attendance records
elif choice == '6':
student_id = int(input("Enter student ID for marks: "))
subject = input("Enter subject name: ")
score = int(input("Enter score: "))
roll_no = input("Enter student roll number: ")
class_code = input("Enter student class: ")
sms.add_marks(student_id, subject, score, roll_no, class_code) # Add marks
elif choice == '7':
sms.view_marks() # View marks records
elif choice == '8':
print("Exiting admin menu...")
break # Exit admin menu

else:
print("Invalid choice.")

elif sms.current_user_role == "student": 13


print("\n--- Student Menu ---")
print("1. View Attendance")
print("2. View Marks")
print("3. Exit")
choice = input("Enter your choice: ")

if choice == '1':
sms.view_attendance() # View attendance records
elif choice == '2':
sms.view_marks() # View marks records
elif choice == '3':
print("Exiting student menu...")
break # Exit student menu

else:
print("Invalid choice.")
sms.close_connection() # Ensure the database connection is closed on exit

14
OUTPUT

15

User Authentication Interface:


Admin Interface:

Student Interface:

16
BIBLIOGRAPHY

Computer Science with Python
by Sumita Arora, for class 11th
and 12th

• W3School, www.w3schools.com
17

You might also like