You are on page 1of 34

DOON INTERNATIONAL SCHOOL

SESSION-2021-22
INFORMATICS PRACTICES (065)

Roll No. 23664557

SUBMITTED TO: SUBMITTED BY:


Mr. Narain Sir Abhay Kashyap
Class-12th-A

Page 1 of 34
Certificate
NAME: Abhay Kashyap CLASS: XII-A
Roll No. 23664557
Institution: Doon International School
This is certified to be bonafide work of the
student in the INFORMATICS PRACTICES (065)
during the academic year 2021-22.

________________ _________________
Principal’s Sign Teacher In-charge

________________ _________________
Examiner’s Sign Rubber Stamp

Acknowledgement
Page 2 of 34
The completion of this project was a really
different task to be performed without
encouragement, valuable suggestion and noble
guidance of our learned and honourable
teachers who helped me a lot every stage
under this patronage.
I especially thanks to Principal Ma’am and
also thankful to Narain Sir who provided the
necessary facilities regarding this activity.
With Thanks……………………

Page 3 of 34
SCHOOL MANAGEMENT
DATABASE

SCHOOL MANAGEMENT
DATABASE

Page 4 of 34
import mysql.connector
mydb1 = mysql.connector.connect(host="localhost",user="root",passwd="root")

CREATE DATABASE CODE


def mydb():

Page 5 of 34
try:
mycursor = mydb1.cursor()
mycursor.execute("CREATE DATABASE SCHOOLmgmt")
mydb1.close()
except:
table()

Page 6 of 34
CREATE TABLE CODE
def table():

try:

mydb1=mysql.connector.connect(host='localhost', user='root', passwd='root', database='SCHOOLmgmt')

mycursor = mydb1.cursor()

mycursor.execute("Create table student(RegNo int(4),SName varchar(30) ,FName varchar(30) ,MName


varchar(30) ,\

Gender varchar(1) ,dob date ,Class varchar(4) , Sec varchar(1) ,Address varchar(40) ,\

Mobile int,Stream varchar(20) , email varchar(30) )")

mycursor = mydb1.cursor()

mycursor.execute("Create table teacher(tno int(4) , TName varchar(20) , Gender varchar(1) ,\

Designation varchar(20) , DOJ date , Address varchar(40) , City varchar(20) , Pin int(6) ,\

Qualifications varchar(30) , MobileNumber int(14) , Graduationsubject varchar(40) ,\

PGraduationsubject varchar(40))")

mydb1.close()

except:

print('You Can Proceed Now')

mydb()

table()

import createDB

import student
Page 7 of 34
import Teacher

import os

import platform

Program

def menu():

createDB.mydb()

while True:

print("""

----------------------------------------------------------

|==========================================================|

|======== Welcome To School Management System ========|

|==========================================================|

----------------------------------------------------------

Enter 1 : Student

Enter 2 : Teacher

Enter 3 : Exit

""")

try: #Using Exceptions For Validation

userInput = int(input("Please Select An Above Option: ")) #Will Take Input From User

except ValueError:

exit("\nHy! That's Not A Number") #Error Message

else:

print("\n") #Print New Line

if(userInput == 1): #This Option Will Print List Of Students

student.menu()

elif(userInput == 2): #This Option Will Add New Student In The List

Teacher.menu()

else:

break

menu()

##runAgain()

Page 8 of 34
STUDENT INFORMATION

Page 9 of 34
import mysql.connector
import os
import platform
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="root",database='schoolmgmt')

DISPLAY STUDENT DATA


Page 10 of 34
def display():
os.system('cls')
mycursor=mydb.cursor()
query=("select * from student")
mycursor.execute(query)
print("====================================================")
print("RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email")
print("====================================================")
for (RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email ) in
mycursor:
print(RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email )
print("====================================================")

ADD STUDENT DATA


Page 11 of 34
def insertData():
try:
mycursor=mydb.cursor()
RegNo = input("Enter Student Roll No: ")
SName = input("Enter Student Name: ")
FName = input("Enter Father's Name : ")
MName=input("Enter Mother's Name :")
Gender=input("Enter Gender type (M/F/T) : ")
dob=input("Enter date of birth :")
Class=input("Enter Class in Roman Number :")
Sec=input("Enter Section :")
Address=input("Enter Address :")
Mobile=input("Enter Mobile Number :")
Stream=input("Enter Stream(Science/Commerce/Arts) :")
email=input("Enter email id :")
query=("insert into Student values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)")
data=(RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email )
mycursor.execute(query,data)
print("================= Record Inserted Successfully======================")
mydb.commit()
print(mycursor.rowcount," Saved")
except mysql.connector.Error as err:
print(err)

Page 12 of 34
SEARCH STUDENT
def search():
try:
print("1. Search By RollNo :")
print("2. Search By Name :")
print("3. Search By Gender :")
print("4. All Record ")
ch=int(input("Enter your choice :"))
if(ch==1):
mycursor=mydb.cursor()
roll_no = input("Enter New Student Roll No: ")
query=("select * from Student where RegNo=%s ")
data=(roll_no,)
mycursor.execute(query,data)
for (RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email ) in
mycursor:
print("====================================================")
print("Student Roll No : ",RegNo)
print("Student Name : ",SName)
print("Father's Name : ",FName)
print("Mother’s Name :",Gender)
print("Gender : ",Gender)
print("date of birth :",dob)
print("Class :",Class)
print("Section :",Sec)
print("Address :",Address)
print("Mobile Number :", Mobile )
print("Stream :",Stream )
print("email id :", email)
print("====================================================")
elif(ch==2):
mycursor=mydb.cursor()
Page 13 of 34
Name = input("Enter Student Name: ")
query=("select * from Student where SName=%s ")
data=(Name,)
mycursor.execute(query,data)
for (RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email ) in
mycursor:
print("====================================================")
print("Student Roll No : ",RegNo)
print("Student Name : ",SName)
print("Father's Name : ",FName)
print("Mother’s Name :",Gender)
print("Gender : ",Gender)
print("date of birth :",dob)
print("Class :",Class)
print("Section :",Sec)
print("Address :",Address)
print("Mobile Number :", Mobile )
print("Stream :",Stream )
print("email id :", email)
print("====================================================")
elif(ch==3):
mycursor=mydb.cursor()
Gender = input("Enter Student Gender: ")
query=("select * from Student where Gender=%s ")
data=(Gender,)
mycursor.execute(query,data)
print("RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email ")
for (RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email ) in
mycursor:
print("="*90)
print(RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email )
print("="*90)

Page 14 of 34
elif(ch==4):
mycursor=mydb.cursor()

query=("select * from Student")


mycursor.execute(query)
print("RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email ")
print("="*80)
for (RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email ) in
mycursor:
print(RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email )
print("="*80)
except mysql.connector.Error as err:
print(err)

Page 15 of 34
DELETE STUDENT
def delete():
try:
print("1. Delete By RollNo :")
print("2. Delete By Name :")
print("3. Delete By Gender :")
print("4. All Record ")
ch=int(input("Enter your choice :"))
if(ch==1):
mycursor=mydb.cursor()
roll_no = input("Enter Student Roll No: ")
query=("select * from Student where RegNo=%s ")
data=(roll_no,)
mycursor.execute(query,data)
for (RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email ) in
mycursor:
print("====================================================")
print("Student Roll No : ",RegNo)
print("Student Name : ",SName)
print("Father's Name : ",FName)
print("Mother’s Name :",Gender)
print("Gender : ",Gender)
print("date of birth :",dob)
print("Class :",Class)
print("Section :",Sec)
print("Address :",Address)
print("Mobile Number :", Mobile )
print("Stream :",Stream )
print("email id :", email)
d=input("Do you want to delete (y/n) :")
if(d=='y' or d=='n'):
mycursor=mydb.cursor()
Page 16 of 34
query=("delete from Student where RegNo=%s ")
data=(roll_no,)
mycursor.execute(query,data)
elif(ch==2):
mycursor=mydb.cursor()
Name = input("Enter Student Name: ")
query=("select * from Student where SName=%s ")
data=(Name,)
mycursor.execute(query,data)
for (RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email ) in
mycursor:
print("====================================================")
print("Student Roll No : ",RegNo)
print("Student Name : ",SName)
print("Father's Name : ",FName)
print("Mother’s Name :",Gender)
print("Gender : ",Gender)
print("date of birth :",dob)
print("Class :",Class)
print("Section :",Sec)
print("Address :",Address)
print("Mobile Number :", Mobile )
print("Stream :",Stream )
print("email id :", email)
print("====================================================")
if(d=='y' or d=='n'):
mycursor=mydb.cursor()
query=("delete from Student where SName=%s ")
data=(Name,)
mycursor.execute(query,data)
elif(ch==3):
mycursor=mydb.cursor()

Page 17 of 34
Gender = input("Enter Student Gender: ")
query=("select * from Student where Gender=%s ")
data=(Gender,)
mycursor.execute(query,data)
print("RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email ")
for (RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email ) in
mycursor:
print("====================================================")
print(RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email )
print("====================================================")
if(d=='y' or d=='n'):
mycursor=mydb.cursor()
query=("delete from Student where gender=%s ")
data=(Name,)
mycursor.execute(query,data)
elif(ch==4):
mycursor=mydb.cursor()
query=("select * from Student")
mycursor.execute(query)
print("RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email ")
print("="*80)
for (RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email ) in
mycursor:
print(RegNo,SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email )
print("="*80)
except mysql.connector.Error as err:
print(err)

MODIFY STUDENT DATA


Page 18 of 34
def modify():
try:
roll_no = input("Enter Student Roll No: ")
s_name = input("Enter Student Name: ")
s_fname = input("Enter Student fname: ")
s_mname = input("Enter Student mname: ")
s_Gender = input("Enter Student Gender: ")
s_dob = input("Enter Student dob: ")
s_class = input("Enter Student class: ")
s_sec = input("Enter Student sec: ")
s_mobile = input("Enter Student Mobile No: ")
s_stream = input("Enter Student stream No: ")
s_Address = input("Enter Student Address: ")
s_email = input("Enter Student email: ")
mycursor=mydb.cursor()
query=("update student set Sname=%s,Fname=%s,Mname=%s, Gender=%s,dob=%s,class=%s,sec=
%s,address=%s,mobile=%s,\
stream=%s,email=%s where RegNo=%s ")
data=(SName ,FName ,MName ,Gender ,dob ,Class ,Sec ,Address , Mobile ,Stream , email,RegNo )
mycursor.execute(query,data)
mydb.commit()
except mysql.connector.Error as err:
print(err)

STUDENT MENU
def menu():
Page 19 of 34
while True:
print("""
----------------------------------------------------------
|==========================================================|
|======== Welcome To Student Management System ========|
|==========================================================|
----------------------------------------------------------
Enter 1 : To View Student's List
Enter 2 : To Add New Student
Enter 3 : To Search Student by roll no
Enter 4 : To Remove Student
Enter 5 : To Modify Student
Enter 6 : To Exit
""")
try: #Using Exceptions For Validation
userInput = int(input("Please Select An Above Option: ")) #Will Take Input From User
except ValueError:
exit("\nHy! That's Not A Number") #Error Message
else:
print("\n") #Print New Line
if(userInput == 1): #This Option Will Print List Of Students
display()
elif(userInput == 2): #This Option Will Add New Student In The List
insertData()
elif(userInput == 3): #This Option Will Add New Student In The List
search()
elif(userInput == 4): #This Option Will Add New Student In The List
delete()
elif(userInput == 5): #This Option Will Add New Student In The List
modify()
else:
break
##search()

Page 20 of 34
##insertData()
##delete()
##menu()

TEACHER DATA
import mysql.connector
Page 21 of 34
import os
import platform
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="root",database='schoolmgmt'
)

DISPLAY TEACHER DATA


def display():
os.system('cls')
Page 22 of 34
mycursor=mydb.cursor()
query=("select * from Teacher")
mycursor.execute(query)
print("="*80)
print("TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub")
print("="*80)
for (TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub)in
mycursor:

print(TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub)
print("="*80)

ADD NEW TEACHER


def insertData():
try:

Page 23 of 34
mycursor=mydb.cursor()
TNo = input("Enter Teacher No: ")
TName = input("Enter Teacher Name: ")
Gender = input("Enter Gender : ")
Designation=input("Enter Designation :")
Doj=input("Enter DOJ : ")
Add=input("Enter Address :")
City=input("Enter City :")
Pin=input("Enter Pin :")
Qual=input("Enter Qualifications :")
Mobileno=input("Enter Mobile Number :")
Gradsub=input("Enter Graduation subject :")
Pgradsub=input("Enter PGraduation subject:")
query=("insert into Teacher values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)")
data=(TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub)
mycursor.execute(query,data)
print("================= Record Inserted Successfully======================")
mydb.commit()
print(mycursor.rowcount," Saved")
except mysql.connector.Error as err:
print(err)

SEARCH TEACHER
def search():
try:

Page 24 of 34
print("1. Search By TNo :")
print("2. Search By TName :")
print("3. Search By Gender :")
print("4. All Record ")
ch=int(input("Enter your choice :"))
if(ch==1):
mycursor=mydb.cursor()
t_no = input("Enter New Teacher No: ")
query=("select * from Teacher where TNo=%s ")
data=(t_no,)
mycursor.execute(query,data)
for x in mycursor:

print("===================================================================================
====")
print(" Teacher No: ",x[0])
print("Teacher Name: ",x[1])
print(" Gender : ",x[2])
print(" Designation :",x[3])
print(" DOJ : ",x[4])
print(" Address :",x[5])
print(" City :",x[6])
print(" Pin :",x[7])
print(" Qualificat14ions :",x[8])
print(" Mobile Number :",x[9])
print(" Graduation subject :",x[10])
print(" PGraduation subject:",x[11])

print("===================================================================================
=====")

elif(ch==2):

Page 25 of 34
mycursor=mydb.cursor()
Name = input("Enter Teacher Name: ")
query=("select * from Teacher where TName=%s ")
data=(Name,)
mycursor.execute(query,data)
for x in mycursor:
print("====================================================")
print(" Teacher No: ",x[0])
print("Teacher Name: ",x[1])
print(" Gender : ",x[2])
print(" Designation :",x[3])
print(" DOJ : ",x[4])
print(" Address :",x[5])
print(" City :",x[6])
print(" Pin :",x[7])
print(" Qualifications :",x[8])
print(" Mobile Number :",x[9])
print(" Graduation subject :",x[10])
print(" PGraduation subject:",x[11])
print("====================================================")
elif(ch==3):
mycursor=mydb.cursor()
Gender = input("Enter Teacher Gender: ")
query=("select * from Teacher where Gender=%s ")
data=(Gender,)
mycursor.execute(query,data)
print(TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub)

for (TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub) in
mycursor:
print("="*90)
print(TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub)

Page 26 of 34
print("="*90)
elif(ch==4):
mycursor=mydb.cursor()
query=("select * from Teacher")
mycursor.execute(query)
print("TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub")
print("="*80)
for (TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub)in
mycursor:
print(TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub)
print("="*80)
except mysql.connector.Error as err:
print(err)

DELETE TEACHER
def delete():
try:
print("1. Delete By TNo :")

Page 27 of 34
print("2. Delete By TName :")
print("3. Delete By Gender :")
print("4. All Record ")
ch=int(input("Enter your choice :"))
if(ch==1):
mycursor=mydb.cursor()
T_no = input("Enter Teacher No: ")
query=("select * from Teacher where TNo=%s ")
data=(T_no,)
mycursor.execute(query,data)
for x in mycursor:
print("====================================================")
print(" Teacher No: ",x[0])
print("Teacher Name: ",x[1])
print(" Gender : ",x[2])
print(" Designation :",x[3])
print(" DOJ : ",x[4])
print(" Address :",x[5])
print(" City :",x[6])
print(" Pin :",x[7])
print(" Qualifications :",x[8])
print(" Mobile Number :",x[9])
print(" Graduation subject :",x[10])
print(" PGraduation subject:",x[11])
print("====================================================")
d=input("Do you want to delete (y/n) :")
if(d=='y' or d=='Y'):
mycursor=mydb.cursor()
query=("delete from Teacher where TNo=%s ")
data=(T_no,)
mycursor.execute(query,data)
mydb.commit()
Page 28 of 34
elif(ch==2):
mycursor=mydb.cursor()
Name = input("Enter Teacher Name: ")
query=("select * from Teacher where TeacherName=%s ")
data=(Name,)
mycursor.execute(query,data)
for x in mycursor:
print("====================================================")
print(" Teacher No: ",x[0])
print("Teacher Name: ",x[1])
print(" Gender : ",x[2])
print(" Designation :",x[3])
print(" DOJ : ",x[4])
print(" Address :",x[5])
print(" City :",x[6])
print(" Pin :",x[7])
print(" Qualifications :",x[8])
print(" Mobile Number :",x[9])
print(" Graduation subject :",x[10])
print(" PGraduation subject:",x[11])
print("====================================================")
mycursor=mydb.cursor()
query=("delete from Student where TName=%s ")
data=(Name,)
mycursor.execute(query,data)
mydb.commit()
elif(ch==3):
mycursor=mydb.cursor()
Gender = input("Enter Teacher Gender: ")
query=("select * from Teacher where Gender=%s ")
data=(Gender,)
mycursor.execute(query,data)
Page 29 of 34
print("TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub")
for (TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub)in
mycursor:
print("====================================================")
print("TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub")
print("====================================================")
if(d=='y' or d=='n'):
mycursor=mydb.cursor()
query=("delete from Teacher where gender=%s ")
data=(Name,)
mycursor.execute(query,data)
mydb.commit()
elif(ch==4):
mycursor=mydb.cursor()

query=("select * from Teacher")

mycursor.execute(query)
print("TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub")
print("="*80)
for (TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub)in
mycursor:
print(TNo,TName , Gender ,Designation ,Doj ,Add ,City ,Pin ,Qual ,Mobileno ,Gradsub ,Pgradsub)
print("="*80)
if(d=='y' or d=='n'):
mycursor=mydb.cursor()
query=("delete from Teacher where gender=%s ")
data=(Name,)
mycursor.execute(query,data)
mydb.commit()
except mysql.connector.Error as err:
print(err)

Page 30 of 34
MODIFY TEACHER DATA
def modify():
try:
TNo = input("Enter Teacher No: ")

Page 31 of 34
TName = input("Enter Teacher Name: ")
Gender = input("Enter Gender : ")
Desig=input("Enter Designation :")
Doj=input("Enter DOJ : ")
Add=input("Enter Address :")
City=input("Enter City :")
Pin=input("Enter Pin :")
Qual=input("Enter Qualifications :")
Mobileno=input("Enter Mobile Number :")
Gradsub=input("Enter Graduation subject :")
Pgradsub=input("Enter PGraduation subject:")
mycursor=mydb.cursor()
query=("update teacher set name=%s,gender=%s,mobileno=%s where tno=%s ")
data=(t_name,t_gender,t_mobile,t_no)
mycursor.execute(query,data)
mydb.commit()
except mysql.connector.Error as err:
print(err)

MENU TEACHER DATA


def menu():
while True:
print("""

Page 32 of 34
----------------------------------------------------------
|==========================================================|
|======== Welcome To School Management System ========|
|==========================================================|
----------------------------------------------------------
Enter 1 : To View Teacher's List
Enter 2 : To Add New Teacher
Enter 3 : To Search Teacher
Enter 4 : To Remove Teacher
Enter 5 : To Modify Teacher
Enter 6 : To Exit """)
try: #Using Exceptions For Validation
userInput = int(input("Please Select An Above Option: ")) #Will Take Input From User
except ValueError:
exit("\nHy! That's Not A Number") #Error Message
else:
print("\n") #Print New Line
if(userInput == 1): #This Option Will Print List Of Students
display()
elif(userInput == 2): #This Option Will Add New Student In The List
insertData()
elif(userInput == 3): #This Option Will Add New Student In The List
search()
elif(userInput == 4): #This Option Will Add New Student In The List
delete()
elif(userInput == 5): #This Option Will Add New Student In The List
modify()
else:
break
##search()
##insertData()
##delete()
##menu()

Page 33 of 34
Page 34 of 34

You might also like