PROJECT
PROJECT
Shahjahanpur
Shift-II
Session 2022-23
Project report on
“MARKS MANAGEMENT SYSTEM”
Mrs. Sonali
Dhondhiyal
PGT (CS)
Acknowledgement
I would like to express my special thanks of
gratitude to my teacher as well as our
principal sir who gave me the golden
opportunity to do this wonderful project on
the topic Database Connectivity, which
also helped me in doing a lot of Research
and I came to know about so many new
things I am really thankful to them.
Secondly, I would also like to thank my
parents and friends who helped me a lot in
finalizing this project within the limited time
frame.
PYTHON CODE
import mysql.connector #import mysql.connector package
import sys
mycon = mysql.connector.connect(host='localhost',user='root',passwd='root')
if mycon.is_connected(): #True if connected otherwise False
print("Python is connected to MYSQL Successfully.")
cur=mycon.cursor() #Create the cursor object to execute SQL queries
cur.execute("Create database if not exists Project23") #Creating Database
cur.execute("Use Project23") #Using Database
cur.execute("Create table if not exists Subject (scode char(3) primary key,
sname varchar(30) not null , cls int(2) not null)")
cur.execute("Create table if not exists Exams (ename varchar(20), edate
date, cls int(2), scode char(3) references Subject(scode))")
cur.execute("Create table if not exists Student( \
admn int(6) primary key, name char(40) not null, cls int(2) not
null, gender char(1), \
sub1 char(3) references Subject(scode), sub2 char(3) references
Subject(scode), sub3 char(3) references Subject(scode),\
sub4 char(3) references Subject(scode), sub5 char(3) references
Subject(scode), sub6 char(3) references Subject(scode), roll int(3))")
cur.execute("Create table if not exists Marks (scode char(3) references
Subject(scode), ename varchar(20) references Exam(ename), \
cls int(2), admn int(6) references
Student(admn), mark int(3), mm int(3), per decimal(5,2))")
else:
print("Python is not connected to MYSQL Successfully. Connection Failed.")
sys.exit()
def Add_Subject():
scode=input("Enter the Subject Code ::")
sname=input("Enter the Subject Name ::")
cls=input("Enter the Class ::")
query="INSERT INTO SUBJECT VALUES(%s,%s,%s)"
values=(scode,sname,cls)
cur.execute(query,values)
mycon.commit()
print("Subject Added Successfully")
return
def Delete_Subject():
scode=input("Enter the subject code to delete the subject :")
cur.execute("SELECT SNAME FROM SUBJECT WHERE SCODE=%s",(scode,) )
rs=cur.fetchone()
if rs:
cur.execute("DELETE FROM SUBJECT WHERE SCODE=%s ",(scode,) )
mycon.commit()
print(rs[0], ", Subject Deleted Successfully")
else:
print("No Such Subject exits !")
return
def View_Subjects() :
cur.execute("SELECT * FROM SUBJECT")
data=cur.fetchall()
if cur.rowcount>0:
print("SCODE \t\t SNAME \t\t CLASS")
print(f'{a:-^50}')
for row in data:
print(row[0],"\t\t",row[1],"\t\t",row[2])
print(f'{a:-^50}')
else:
print("No Data Found")
return
def Add_Exam():
cls=input("Enter the Class ::")
ename=input("Enter the Exam Name (PA-1,PA-2,Half Yearly,etc) ::")
def View_Exams():
cls=input("Enter the Class ::")
query="Select * from EXAMS where cls="+cls+" order by edate"
print("Exam \t Date Of Exam \t SUBJECT NAME")
cur.execute(query)
data=cur.fetchall()
for i in range(cur.rowcount):
scode=data[i][3]
cur.execute("Select sname from SUBJECT where cls="+cls+" and
scode="+scode)
sname=cur.fetchone()[0]
print(data[i][0],"\t",data[i][1],"\t",sname,"\t",)
return
def Add_Student():
admn=input("Enter the Admission Number ::")
name=input("Enter the Student Name ::")
cls=input("Enter the Class ::")
gen=input("Enter the Gender ::")
s1=input("Enter the Code for Subject 1 ::")
s2=input("Enter the Code for Subject 2 ::")
s3=input("Enter the Code for Subject 3 ::")
s4=input("Enter the Code for Subject 4 ::")
s5=input("Enter the Code for Subject 5 ::")
s6=input("Enter the Code for Subject 6 (Press Enter to Leave Blank) ::")
cur.execute("SELECT MAX(ROLL) FROM STUDENT WHERE CLS =%s",(cls,) )
r=cur.fetchone()[0]
if r==None:
roll=1
else:
roll=str(int(r)+1)
query="INSERT INTO STUDENT VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,
%s)"
values=(admn,name,cls,gen,s1,s2,s3,s4,s5,s6,roll)
cur.execute(query,values)
mycon.commit()
print("Student Added Successfully")
return
def Delete_Student():
admn=input("Enter the admission number to delete the Student :")
cur.execute("SELECT NAME FROM STUDENT WHERE ADMN=%s",(admn,) )
rs=cur.fetchone()
if rs:
cur.execute("DELETE FROM STUDENT WHERE ADMN=%s ",(admn,) )
cur.execute("DELETE FROM MARKS WHERE ADMN=%s ",(admn,) )
mycon.commit()
print(rs[0], ", Student and his/her Marks Deleted Successfully from the
database")
else:
print("No Such Student Found !")
return
def View_Students() :
cur.execute("SELECT * FROM STUDENT")
data=cur.fetchall()
if cur.rowcount>0:
print("ADMN \t NAME \t\t CLASS \t GEN \t SUB1 \t SUB1 \t SUB3 \t SUB4 \
t SUB5 \t SUB6 \t ROLLno")
print(f'{a:-^150}')
for row in data:
print(row[0],"\t",row[1],"\t",row[2],"\t",row[3],"\t",row[4],"\
t",row[5],"\t",row[6],"\t",row[7],"\t",row[8],"\t",row[9],"\t",row[10])
print(f'{a:-^150}')
else:
print("No data found")
return
def Add_Marks():
sub_code=input("Enter the Subject Code ::")
cls=input("Enter the Class ::")
for i in range(cur.rowcount):
if ename==i+1:
exam=data[i][0]
def Update_Marks_Absentee():
sub_code=input("Enter the Subject Code ::")
cls=input("Enter the Class ::")
for i in range(cur.rowcount):
if ename==i+1:
exam=data[i][0]
values=(sub_code,cls,exam)
cur.execute(query,values)
data=cur.fetchall()
if cur.rowcount==0:
print("No Absentee found")
return
def Update_Marks_Failures():
sub_code=input("Enter the Subject Code ::")
cls=input("Enter the Class ::")
for i in range(cur.rowcount):
if ename==i+1:
exam=data[i][0]
values=(sub_code,cls,exam)
cur.execute(query,values)
data=cur.fetchall()
if cur.rowcount==0:
print("No Failure student found")
return
def View_Marks() :
sub_code=input("Enter the Subject Code :")
cls=input("Enter the Class :")
return
while ch=='1':
text="<< Subject Management >>"
print(f'{text:+^50}')
print("\n1. << Add New Subject >>")
print("2. << Delete Any Subject>>")
print("3. << View All Subjects>>")
print("4. << Go to Main Menu>>\n")
s=input("Enter choice (1-4) >>")
if s=='1':
Add_Subject()
elif s=='2':
Delete_Subject()
elif s=='3':
View_Subjects()
elif s=='4':
break
else:
print(" Invalid Input !!!!. Enter your choice from 1 to 4")
while ch=='2':
text="<< Student Management >>"
print(f'{text:+^50}')
print("\n1. << Add New Student >>")
print("2. << Delete Any Student>>")
print("3. << View All Students>>")
print("4. << Go to Main Menu>>\n")
s=input("Enter choice (1-4) >>")
if s=='1':
Add_Student()
elif s=='2':
Delete_Student()
elif s=='3':
View_Students()
elif s=='4':
break
else:
print(" Invalid Input !!!!. Enter your choice from 1 to 4")
while ch=='3':
text="<< Exam Details Management >>"
print(f'{text:+^50}')
print("\n1. << Add Exam Details >>")
print("2. << View Exam Details >>")
print("3. << Go to Main Menu>>\n")
s=input("Enter choice (1-3) >>")
if s=='1':
Add_Exam()
elif s=='2':
View_Exams()
elif s=='3':
break
else:
print(" Invalid Input !!!!. Enter your choice from 1 to 3")
while ch=='4':
text="<< Marks Management >>"
print(f'{text:+^50}')
print("\n1. << Add Marks for a Subject >>")
print("2. << Update Marks of Absentee Students>>")
print("3. << Update Marks for failure>>")
print("4. << View Marks for a Subject>>")
print("5. << Go to Main Menu>>\n")
s=input("Enter choice (1-4) >>")
if s=='1':
Add_Marks()
elif s=='2':
Update_Marks_Absentee()
elif s=='3':
Update_Marks_Failures()
elif s=='4':
View_Marks()
elif s=='5':
break
else:
print(" Invalid Input !!!!. Enter your choice from 1 to 5")
if ch=='5':
break
else:
print("Enter your choice from 1 to 5")
OUTPUT
Python is connected to MYSQL Successfully.
1 . MATHEMATICS
Enter the Exam Date (YYYY/MM/DD) ::2022/10/10
2 . PHYSICS
Enter the Exam Date (YYYY/MM/DD) ::2022/10/05
3 . CHEMISTRY
Enter the Exam Date (YYYY/MM/DD) ::2022/10/06
4 . BIOLOGY
Enter the Exam Date (YYYY/MM/DD) ::2022/10/01
5 . COMPUTER SCIENCE
Enter the Exam Date (YYYY/MM/DD) ::2022/10/03
6 . ENGLISH CORE
Enter the Exam Date (YYYY/MM/DD) ::2022/10/12
7 . HINDI CORE
Enter the Exam Date (YYYY/MM/DD) ::2022/10/13
Exam Added Successfully
+++++++++<< Exam Details Management >>++++++++++
1. << Add Exam Details >>
2. << View Exam Details >>
3. << Go to Main Menu>>