ComputerScience Project 2
ComputerScience Project 2
Project REPORT
submiTted By
1|Page
TABLE OF CONTENTS
Certificate
Acknowledgement
Preface of Project
Project Description
Database Design
Project Code
Sample Outputs
Bibliography
2|Page
PREFACE OF PROJECT
I have chosen this Project titled "Student
Management System" along with my Project partner
Sonali Patel. The project will help to build a robust
computerized system for maintaining student records
in a school. The project is designed to make the task of
keeping records of the several students easier and help
you to prepare result sheet of students. The project is
based on database connectivity of MySQL and Python.
I was inclined towards this topic as In the ever-
evolving landscape of education, the efficient
management of student data is pivotal to the success of
academic institutions. This project, the Student
Management System (SMS), is a thoughtful response
to the evolving needs of educational administration in
the digital age. Recognizing the challenges faced by
institutions in handling diverse aspects of student
information, from enrollment to performance
tracking, this project seeks to introduce a
comprehensive solution. Developed with the objective
of enhancing administrative efficiency and promoting
data accuracy, the SMS endeavors to be a reliable tool
3|Page
for educators and administrators alike. By embracing
modern technologies, particularly focusing on the
versatility and capabilities of Python, this system
aspires to redefine the way student information is
handled, offering a centralized, automated, and user-
friendly approach. This preface serves as an
introduction to the project's aspirations,
acknowledging the significance of technology in the
realm of education and emphasizing the
transformative potential of the Student Management
System. As we embark on this technological journey,
the ultimate goal is to contribute to an educational
ecosystem where administrative processes are
streamlined, and educators can focus more on what
truly matters – nurturing the academic growth of the
students.
4|Page
PROJECT DESCRIPTION
The Project uses Python as a programming language
and MySQL as the Backend tool. The Project has two
main modules:
1. User Management
This module allows you to create or delete user records. The module
has a menu-driven interface to login into the Student Management
module with the appropriate username and password.
2. Student Management
5|Page
It also helps in modifying incorrect data, updating student data, the
addition of new students’ data, or the deletion of an existing
student’s data whenever there is a need.
6|Page
HARDWARE & SOFTWARE
SPECIFICATIONS
HARDWARE SPECIFICATIONS:-
Processor : Intel Core I3 and above
Ram : 8 GB
SOFTWARE SPECIFICATIONS:-
Operating System : Windows 11
Database : MySQL
Languages : Python
7|Page
PYTHON MODULES USED
8|Page
4. numpy– for numerical computing that facilitates
the manipulation of large.
5. tabulate– for creating nicely formatted tables
DATABASE DESIGN
mysql> CREATE DATABASE School;
9|Page
SOURCE CODE (PYTHON)
import sys
import mysql.connector
import pandas as pdf
import numpy as np
from tabulate import tabulate
def usermenu():
while True:
print("\t\t--------------------------")
print("\t\t1. Add New User")
print("\t\t2. Delete User")
print("\t\t3. Login to MainMenu")
10 | P a g e
print("\t\t4. Exit")
print("\t\t--------------------------")
choice=eval(input("Enter your
choice:"))
if choice==1:
adduser()
elif choice==2:
deleteuser()
elif choice==3:
login()
else:
sys.exit()
def adduser():
try:
print("-----Enter New User
Details-------")
11 | P a g e
user=input("Enter Username:")
pwd=input("Input Password:")
if mydb.is_connected():
mycursor=mydb.cursor()
sql="Insert into Users
values('"+user+"','"+pwd+"')"
mycursor.execute(sql)
mydb.commit()
print("New User Registered
Successfully")
else:
print("User Registration
Unsuccessful")
except Exception as e:
print("Error",e)
def deleteuser():
12 | P a g e
try:
user=input("Enter Username to
delete:")
if mydb.is_connected():
mycursor=mydb.cursor()
sql="Delete From Users where
user='"+user+"'"
mycursor.execute(sql)
mydb.commit()
if (mycursor.rowcount!=0):
print("User record deleted
successfully")
else:
print("User record does not
exists!!!")
except Exception as e:
print("Error",e)
13 | P a g e
def login():
try:
mydb=mysql.connector.connect(host="localh
ost",user="root",password="root",database=
'school')
user=input("Enter Username:")
pwd=input("Input Password:")
if mydb.is_connected():
mycursor=mydb.cursor()
sql="Select * from users where
user='"+user+"'"
mycursor.execute(sql)
myrecord=mycursor.fetchone()
if mycursor.rowcount==1:
if myrecord[1]==pwd:
print("User: "+user+ ", Login
Successfull")
14 | P a g e
mainmenu(user)
else:
print("Invalid password")
elif mycursor.rowcount==-1:
print("Invalid username")
except Exception as e:
print("Error",e)
def mainmenu(user):
while True:
print("\t\t-----MAIN MENU------User:
"+user)
print("\t\t-------------------------------")
print("\t\t1. Add Student Detail")
print("\t\t2. Update Student Detail")
print("\t\t3. Search Student Detail")
print("\t\t4. Delete Student Detail")
15 | P a g e
print("\t\t5. Show All Result")
print("\t\t6. Show All Student Details")
print("\t\t7. Show Summary in Order")
print("\t\t8. Display topper details")
print("\t\t9. Log Out")
print("\t\t0. Exit")
print("\t\t-------------------------------")
choice=eval(input("Enter your
choice:"))
if choice==1:
addstudent()
elif choice==2:
updatestudent()
elif choice==3:
searchmenu()
elif choice==4:
deletestudent()
16 | P a g e
elif choice==5:
showallresult()
elif choice==6:
showall()
elif choice==7:
showorderwise()
elif choice==8:
showtopper()
elif choice==9:
break
elif choice==0:
sys.exit()
def addstudent():
try:
regno=initregno()
print(regno)
17 | P a g e
print("-----Input New Student
Details-----")
name=input("Enter student name: ")
cls=int(input("Enter standard/class:"))
gender=input("Enter gender
(male/female):")
address=input("Enter address:")
contact=input("Enter contact no.: ")
dob=input("Enter date of birth(yyyy-
mm-dd): ")
pm=int(input("Enter physics marks: "))
cm=int(input("Enter chemistry marks:
"))
mm=int(input("Enter maths marks: "))
if mydb.is_connected():
mycursor=mydb.cursor()
sql="Insert into Students
values("+str(regno)+",'"+name+"',"+str(cls)
18 | P a g e
+",'"+gender+"','"+address+"','"+contact+"',
'"+dob+"',"+str(pm)+","+str(cm)
+","+str(mm)+")"
mycursor.execute(sql)
mydb.commit()
print("New Student Record Added
Successfully")
else:
print("New Student Record Insertion
Unsuccessful")
except Exception as e:
print("Error",e)
def initregno():
try:
if mydb.is_connected():
mycursor=mydb.cursor()
19 | P a g e
sql="Select max(regno) from
students"
mycursor.execute(sql)
myrecord=mycursor.fetchone()
if myrecord==(None,):
regno=1
else:
regno=int(myrecord[0])+1
return regno
except Exception as e:
print("Error",e)
def updatestudent():
try:
regno=int(input("Enter Student
Registration No:"))
while True:
20 | P a g e
print("\t\
t----------------------------------")
print("\t\t1. To update name")
print("\t\t2. To update class")
print("\t\t3. To update gender")
print("\t\t4. To update address")
print("\t\t5. To update contact
no.")
print("\t\t6. To update dob")
print("\t\t7. To update physics
marks")
print("\t\t8. To update chemistry
marks")
print("\t\t9. To update maths
marks")
print("\t\t0. To go back to
mainmenu")
choice=int(input("Enter your
choice: "))
21 | P a g e
if choice==1:
name=input("Enter name: ")
updatedetail(regno,"name",2,name)
elif choice==2:
cls=input("Enter class: ")
updatedetail(regno,"class",1,cls)
elif choice==3:
gender=input("Enter gender
(male/female): ")
updatedetail(regno,"gender",2,gender)
elif choice==4:
address=input("Enter address:
")
updatedetail(regno,"address",2,address)
elif choice==5:
22 | P a g e
contact=input("Enter contact
no.: ")
updatedetail(regno,"contact",2,contact)
elif choice==6:
dob=input("Enter date of
birth(yyyy-mm-dd): ")
updatedetail(regno,"dob",2,dob)
elif choice==7:
pm=input("Enter physics
marks: ")
updatedetail(regno,"pm",1,pm)
elif choice==8:
cm=input("Enter chemistry
marks: ")
updatedetail(regno,"cm",1,cm)
elif choice==9:
23 | P a g e
mm=input("Enter maths
marks: ")
updatedetail(regno,"mm",1,mm)
elif choice==0:
break
except Exception as e:
print("Error",e)
def
updatedetail(regno,field,dtype,newvalue):
try:
if mydb.is_connected():
mycursor=mydb.cursor()
if dtype==1:
sql="Update Students Set
"+field+"="+newvalue+" where
regno="+str(regno)
24 | P a g e
else:
sql="Update Students Set
"+field+"='"+newvalue+"' where
regno="+str(regno)
mycursor.execute(sql)
mydb.commit()
if (mycursor.rowcount!=0):
print("Student record updated
successfully")
else:
print("Student record does not
exists!!!")
except Exception as e:
print("Error",e)
def searchmenu():
try:
while True:
25 | P a g e
print("\t\
t----------------------------------")
print("\t\t1. Search By RegNo")
print("\t\t2. Search By Name")
print("\t\t3. Search By Class")
print("\t\t0. To go back to
mainmenu")
choice=int(input("Enter your
choice: "))
if choice==1:
searchstudent("regno")
elif choice==2:
searchstudent("name")
elif choice==3:
searchstudent("class")
elif choice==0:
break
except Exception as e:
26 | P a g e
print("Error",e)
def searchstudent(field):
try:
if mydb.is_connected():
mycursor=mydb.cursor()
value=input("Enter value to
search:")
if field == "Name":
sql="Select * From Students
Where %s='%s'" %(field,value)
else:
sql="Select * From Students
Where %s='%s'" %(field,value)
mycursor.execute(sql)
records = mycursor.fetchall()
if mycursor.rowcount!=0:
count=0
27 | P a g e
for record in records:
displayrecord(record)
count=count+1
if count%3==0:
ch=input("Press any key to
continue")
mydb.commit()
except Exception as e:
print("Error",e)
def displayrecord(rec):
try:
print("Reg No: ",rec[0],"\tName:
",rec[1],"\t\tClass: ",rec[2],"\tGender:
",rec[3])
print("Address: ",rec[4])
print("Contact No: ",rec[5],"\tBirth
Date: ",rec[6])
28 | P a g e
print("Physics: ",rec[7],"\tChemistry:
",rec[8],"\tMaths: ",rec[9],"\tTotal: ",
(rec[7]+rec[8]+rec[9]),"\tPercent: ",
(rec[7]+rec[8]+rec[9])/3)
print("-------------------------------------------
---------------------------------------------------
-----")
except Exception as e:
print("Error",e)
def deletestudent():
try:
regno=int(input("Enter Student
Registration No:"))
if mydb.is_connected():
mycursor=mydb.cursor()
sql="Delete From Students where
regno="+str(regno)
29 | P a g e
mycursor.execute(sql)
mydb.commit()
if (mycursor.rowcount!=0):
print("Student record deleted
successfully")
else:
print("Student record does not
exists!!!")
except Exception as e:
print("Error",e)
def showallresult():
try:
if mydb.is_connected():
mycursor=mydb.cursor()
sql="Select
regno,name,class,gender,contact,dob,pm,cm,
30 | P a g e
mm,(pm+cm+mm)/3 From Students Order
By RegNo"
mycursor.execute(sql)
records = mycursor.fetchall()
colnames=["RegNo","Name","Class","Gender
","Contact","BirthDate","Physics","Chemistry"
,"Maths","Percent"]
if mycursor.rowcount!=0:
## print("RegNo StudentName
Class Gender ContactNo. BirthDate
PM CM MM Percent")
##
print("-------------------------------------------
---------------------------------------------------
----------------------")
## for rec in records:
## print("%-9s"%rec[0],"%-
15s"%rec[1],"%-9s"%rec[2],"%-
10s"%rec[3],"%-14s"%rec[4],"%-
31 | P a g e
13s"%rec[5],"%-6s"%rec[6],"%-
6s"%rec[7],"%-6s"%rec[8],"%-7s"%rec[9])
print(tabulate(records,
headers=colnames, tablefmt="grid",
showindex="always"))
else:
print("No records exists")
except Exception as e:
print("Error",e)
def showall():
try:
if mydb.is_connected():
mycursor=mydb.cursor()
sql="Select * From Students Order
By RegNo"
mycursor.execute(sql)
records = mycursor.fetchall()
32 | P a g e
if mycursor.rowcount!=0:
count=0
for record in records:
displayrecord(record)
count=count+1
if count%5==0:
ch=input("Press any key to
continue")
except Exception as e:
print("Error",e)
def showorderwise():
try:
print("Specify Sort Order")
print("1. Display classwise")
print("2. Display namewise")
print("3. Display percentwise")
33 | P a g e
choice=int(input("Enter your choice: "))
if choice==1:
orderfield="class"
elif choice==2:
orderfield="name"
elif choice==3:
orderfield="percent"
if mydb.is_connected():
mycursor=mydb.cursor()
if orderfield=="percent":
sql="Select * From Students
Order By (pm+cm+mm)/3"
else:
sql="Select * From Students
Order By "+orderfield
mycursor.execute(sql)
records = mycursor.fetchall()
34 | P a g e
if mycursor.rowcount!=0:
count=0
for record in records:
displayrecord(record)
count=count+1
if count%5==0:
ch=input("Press any key to
continue")
except Exception as e:
print("Error",e)
def showtopper():
try:
print("\t\t\t\t\t\tTOPPER DETAILS")
print("-------------------------------------------
---------------------------------------------------
------------------------")
35 | P a g e
if mydb.is_connected():
mycursor=mydb.cursor()
sql="Select * From Students Where
(pm+cm+mm) in (Select max(pm+cm+mm)
From Students)"
mycursor.execute(sql)
records = mycursor.fetchall()
if mycursor.rowcount!=0:
count=0
for record in records:
displayrecord(record)
count=count+1
if count%3==0:
ch=input("Press any key to
continue")
except Exception as e:
print("Error",e)
36 | P a g e
print("\tMM MM MMMMMMM MM
MMMMMM MMMMMM MMMMMMMMMM
MMMMMMM")
print("\tMM MM MM MM MM MM
MM MM MM MM MM ")
print("\tMM MM MM MMMMM MM MM
MM MM MM MM MM MMMMM ")
print("\tMM MM MM MM MM MM
MM MM MM MM MM ")
print("\tMMMMMMMMMM MMMMMMM
MMMMMMM MMMMMM MMMMMM MM MM
MMMMMMM ")
print("\t\t\t SSSSSSSS SSSSSS ")
print("\t\t\t SS SS SS ")
print("\t\t\t SS SS SS ")
print("\t\t\t SS SS SS ")
print("\t\t\t SS SSSSSS ")
37 | P a g e
print("\tCOMPUTER PROJECT (********
<<STUDENT MANAGEMENT SYSTEM>>
*******)")
print("\t\t press any KEY???? to continue:
")
try:
mydb=mysql.connector.connect(host="localh
ost",user="root",passwd="root",database='s
chool')
choice=input("Initialize Database (y/n):")
if choice.lower()=='y':
uname=input("Enter username:")
pwd=input("Enter password:")
if uname=="stum" and
pwd=="sonmah":
mycursor=mydb.cursor()
#mycursor.execute("create database
if not exists school")
38 | P a g e
#mycursor.execute("use school")
mycursor.execute("Create table if
not exists Users(User varchar(20) primary
key, password varchar(20))")
mycursor.execute("Create table if
not exists Students(regno int primary
key,name varchar(25),class int,gender
varchar(10),address varchar(100),contact
varchar(10),dob date,pm int,cm int, mm
int)")
print("Initialized....")
usermenu()
else:
print("Authentication failed")
else:
mycursor=mydb.cursor()
mycursor.execute("use school")
usermenu()
except Exception as e:
39 | P a g e
print("Error",e)
40 | P a g e
OUTPUTS of
STUDENT
MANAGEMENT
SYSTEM PROJECT
Welcome Screen
41 | P a g e
Delete User
42 | P a g e
Login using valid User to display Student
Menu
43 | P a g e
To Update Student Record
44 | P a g e
To Search Student Records By Name
45 | P a g e
To Delete Student Record
46 | P a g e
To Show All Student Records
47 | P a g e
To Show Student Record Summary Class
wise
48 | P a g e
To Show Student Record Summary Name
wise
49 | P a g e
To Show Student Record Summary Percent
wise
To Show Topper Student Record
50 | P a g e
To Logout from Main Menu
53 | P a g e
BIBLIOGRAPHY
54 | P a g e
6. https://www.tutorialspoint.com/python/index.htm
55 | P a g e