0% found this document useful (0 votes)
90 views32 pages

Teacher Management (IP)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views32 pages

Teacher Management (IP)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Bhawanathpur Township, Garhwa(JH)-822129

Session- 2020-21

Informatics Practices
(065)

1
DECLARATION
I RIYA STUDENT OF CLASS XII ‘A’, ROLL NO. 22697816 HEREBY DECLARE THAT THE
PRESENTED PROJECT WORK ON ‘TEACHER’S INFO IS AN ORIGINAL CONTENT. THIS
PROJECT WORK HAD NOT BEEN SUBMITTED EARLIER TO ANY OTHER BOARD OR
TO THE SAME BOARD FOR THE FULFILLMENT OF COURSE OF STUDY. IT HAS DONE
BY ME WITH MY GUIDE MR. ANUP SINGH AND WITH MY FRIENDS.

2
PROJECT WORK
ON

TEACHER’S INFO.
SUBMITTED BY:

NAME: RIYA

CLASS: XII ‘A’

BOARD ROLL NO.:22697816

3
ACKNOWLEDGEMENT
THIS IS TO ACKNOWLWDEGE THE CO-OPERATION OF ALL THE INDIVIDUALS WHO
HAVE PLAYED A KEY ROLE IN THE SUCCESS OF THIS PROJECT, WHO HAVE
INSPIRED, MENTORED, DIRECTED AND SEEN THE PROJECT THROUGH ITS
COMPLETION.

I AM SPECIALLY GRATEFUL TO MR. ANUP KR. SINGH MY PROJECT GUIDE


COMPUTER TEACHER, FOR ALLTING ME WORK THAT ENTAILED RESPONSIBILITY
AND FOR HIS GUIDANCE, HELP AND CONSTANT ENCOURAGEMENT THOUGHOUT
THIS PROJECT.

I EXPRESS MY GRATITUDE TO MY FRIENDS AN DMY PARENTS FOR THEIR


ENCOURAGEMENT AND SUPPORT IN OUR ENDEAVOR.

NAME:Riya Kumari

ENROLLMENT:22697816

4
INDEX

TOPIC PAGE NO.

6
TOOLS AND PLATFORM USED

7
My SQL Database

8
TABLE STRUCTURE

PYTHON 9

PYTHON CODING 10-22

OUTPUT 23-30

LIMITATION 31

BIBLIOGRAPHY 32

5
TOOLS AND PLATFORM USED
SOFTWARE

OPERATING SYSTEM : WINDOWS 10

FRONT END : PYTHON 3.7

BACK END : My SQL Server 8.0 or Higher

HARDWARE

PROCESSOR : AMD A8

RAM :512MB

6
My SQL Database
MySQL is a fast, easy-to-use RDBMS being used for many small and big
businesses. MySQL is developed, marketed and supported by MySQL,
which is a Swedish company. MySQL is becoming so popular because of
many good reasons –

 MySQL is released under an open-source license. So you have


nothing to pay to use it.
 MySQL is a very powerful program in its own right. It handles a large
subset of the functionality of the most expensive and powerful
database packages.
 MySQL uses a standard form of the well-known SQL data language.
 MySQL works on many operating systems and with many languages
including Python, PHP, PERL, C, C++, JAVA, etc.
 MySQL works very quickly and works well even with large data sets.
 MySQL is very friendly to PHP, the most appreciated language for
web development.
 MySQL supports large databases, up to 50 million rows or more in a
table. The default file size limit for a table is 4GB, but you can
increase this (if your operating system can handle it) to a theoretical
limit of 8 million terabytes (TB).
 MySQL is customizable. The open-source GPL license allows
programmers to modify the MySQL software to fit their own specific
environments.

In this project MySQL server and Python connector is used. MySQL server
is used to store the data and MySQL-Python connector is used to connect
the program of Python to MySQL server client.

7
TABLE STRUCTURE

8
Python
Python is a popular programming language. It was created by
Guido van Rossum, and released in 1991.

It is used for:

 web development (server-side),


 software development,
 mathematics,
 system scripting.

Modules or Package installed for using this Project


1. mysqlclient: To install this run command (pip install
mysqlclient)

Description: This package contains the MySQLdb module. It


is written in C, and is one of the most commonly used Python
packages for MySQL.

2. pymysql: to install this run command (pip install pymysql)

Description: This package contains the pymysql module. It is


written entirely in Python.

3. python connector: to install this run command (pip install


mysql-connector-python)

Description: This package contains the mysql.connector


module. It is written entirely in Python.

4. Matplotlib: to install this run command (pip install


matplotlib)

Description: This package is install to represent the graphs.

5. Pandas: to install this run command (pip install pandas)


Description: It is used to view data in arranged way.

9
10
CODING
 For mysql connection (to be run once only)
import mysql.connector as sql

conn= sql.connect(host='localhost', user = 'root', password ='root')

c1=conn.cursor()

c1.execute("create database school")

c1.execute("use school")

c1.execute("create table teachers(id int(2), name varchar(20), dept varchar(20), joining_date

varchar(20), gender varchar(20), contact varchar(20), sal int(11))")

 Main Python program

def guestgr():

def deptgraph():

import pymysql

import matplotlib.pyplot as plt

d1=pymysql.connect(host="localhost",user="root",passwd="root",database="school")

11
c1=d1.cursor()

quer="select count(*) from teachers where dept='english';"

c1.execute(quer)

x=c1.fetchone()

lst=list(x)

quer="select count(*) from teachers where dept='history';"

c1.execute(quer)

y=c1.fetchone()

lst1=list(y)

quer="select count(*) from teachers where dept='pol sci';"

c1.execute(quer)

z=c1.fetchone()

lst2=list(z)

quer="select count(*) from teachers where dept='eco';"

c1.execute(quer)

a=c1.fetchone()

lst3=list(a)

quer="select count(*) from teachers where dept='ip';"

c1.execute(quer)

d1.commit()

a=c1.fetchone()

lst4=list(a)

lstt=lst+lst1+lst2+lst3+lst4

y=["English","History","PolSci","Economics","IP"]

plt.bar(y,lstt,width=0.50)

plt.xlabel("Subjects")

12
plt.ylabel("No. of teachers")

plt.show()

deptgraph()

def sexgraph():

import pymysql

import matplotlib.pyplot as plt

d1=pymysql.connect(host="localhost",user="root",passwd="root",database="school")

c1=d1.cursor()

quer="select count(*) from teachers where gender='male';"

c1.execute(quer)

x=c1.fetchone()

lst=list(x)

quer="select count(*) from teachers where gender='female';"

c1.execute(quer)

y=c1.fetchone()

lst1=list(y)

lstt=lst+lst1

y=["Male","Female"]

plt.bar(y,lstt,width=0.50)

plt.xlabel("Sex")

plt.ylabel("no. of teachers")

plt.show()

sexgraph()

print("Want to see record according to:\n 1. deptgraph \n 2. sexgraph")

x=int(input("enter the no:"))

13
if x==1:

deptgraph()

elif x==2:

sexgraph()

elif x!=[1,2]:

print("INVAILD INPUT")

guestgr()

def showallrecords():

import pymysql

import pandas as pd

pd.set_option('display.expand_frame_repr',False)

d1=pymysql.connect(host="localhost",user="root",passwd="root",database="school")

df=pd.read_sql("select*from teachers;",d1)

print(df)

def addrecords():

import pymysql

d1=pymysql.connect(host="localhost",user="root",passwd="root",database="school")

c1=d1.cursor()

print("")

print("SUBJECTS: \n1. english=$30000 \n2. history=$40000 \n3. polsci=$50000 \

n4. eco=$60000 \n5. ip=$70000")

14
print("")

ans1="yes"

while ans1=="yes":

x=int(input("Enter the id:"))

quer1="select * from teachers where id=%d;" %x

c1.execute(quer1)

if c1.rowcount>0:

print("duplicate record")

elif c1.rowcount==0:

ans1="no"

y=input("Enter the name:")

a=input("Enter the dept:")

b=input("Enter the joining date:")

c=input("Enter the gender:")

ans1="yes"

while ans1=="yes":

z=input("Enter the contact no.")

quer="select * from teachers where contact='%s';"

c1.execute(quer)

if c1.rowcount>0:

print("DUPLICATE RECORD")

elif c1.rowcount==0:

ans1="no"

v=int(input("Enter the salary:"))

quer="Insert into teachers values(%d,'%s','%s','%s','%s','%s',

%d);" %(x,y,a,b,c,z,v)

15
c1.execute(quer)

d1.commit()

print("Record Added")

f=input("Want to see the added record y/n: ")

if f=="y":

quer="select * from teachers where id=%d;"%x

c1.execute(quer)

rec=c1.fetchone()

tid,name,dept,joindate,gender,contact,sal=rec

print("id= %d"%tid,"name= %s"%name,"department=

%s"%dept,"joindate= %s"%joindate,"gender= %s"%gender,"contactno=

%s"%contact,"salary= %d"%sal,sep="\n")

else:

print("Thank You")

def search():

import pymysql

import pandas as pd

d1=pymysql.connect(user="root",host="localhost",passwd="root",database="school")

c1=d1.cursor()

print("1. id \n2. contact no.")

x=int(input("enter the no:"))

if x==1:

tid=int(input("enter the id:"))

quer="select * from teachers where id=%d;" % tid

c1.execute(quer)

16
if c1.rowcount>0:

lst=list(c1.fetchone())

iddf=pd.DataFrame({"id":lst[0],"name":lst[1],"dept":lst[2],"joindate":lst[3],"gender":lst[4],"c

ontact":lst[5],"salary":lst[6]},index=[1])

print(iddf)

elif c1.rowcount==0:

print("NO RECORD")

elif x==2:

cno=input("enter the contact no.:")

quer1="select * from teachers where contact='%s'" % cno

c1.execute(quer1)

if c1.rowcount>0:

row1=list(c1.fetchall()[0])

iddf=pd.DataFrame({"id":row1[0],"name":row1[1],"dept":row1[2],"joindate":row1[3],"gend

er":row1[4],"contact":row1[5],"salary":row1[6]},index=[1])

print(iddf)

else:

print("NO RECORD")

else:

print("INVAILD INPUT")

def delete():

import pymysql

d1=pymysql.connect(host="localhost",user="root",passwd="root",database="school")

17
c1=d1.cursor()

x=int(input("enter the id:"))

quer="delete from teachers where id=%d;" %x

rowcount=c1.execute(quer)

if rowcount>0:

d1.commit()

print("Record Deleted")

else:

print("NO RECORD FOUND")

def changerecord():

import pymysql

import pandas as pd

pd.set_option('display.expand_frame_repr',False)

d1=pymysql.connect(user="root",host="localhost",passwd="root",database="school")

c1=d1.cursor()

tid=int(input("enter the id:"))

quer="select * from teachers where id=%d" % tid

c1.execute(quer)

if c1.rowcount>0:

row=list(c1.fetchone())

print('')

df=pd.DataFrame({"id":row[0],"name":row[1],"department":row[2],"joindate":row[3],"gend

er":row[4],"contact":row[5],"salary":row[6]},index=[1])

print(df)

18
print("\n1. id \n2. name \n3. department \n4. joindate \n5. gender \n6. contact \n7.

salary")

cr=int(input("enter the no for what do you want to change:"))

if cr==1:

ans1='yes'

while ans1=="yes":

y=int(input("enter the id:"))

quer1="select * from teachers where id=%d" %y

c1.execute(quer1)

if c1.rowcount>0:

print("DUPLICATE RECORD")

elif c1.rowcount==0:

ans1="no"

quer="update teachers set id=%d where id=%d" %(y,tid)

c1.execute(quer)

d1.commit()

print("RECORD CHANGED")

elif cr==2:

y=input("enter the name:")

quer="update teachers set name='%s' where id=%d" %(y,tid)

c1.execute(quer)

d1.commit()

print("RECORD CHANGED")

elif cr==3:

y=input("enter the department:")

quer="update teachers set dept='%s' where id=%d" %(y,tid)

19
c1.execute(quer)

d1.commit()

print("RECORD CHANGED")

elif cr==4:

y=input("enter the join date:")

quer="update teachers set joining_date='%s' where id=%d" %(y,tid)

c1.execute(quer)

d1.commit()

print("RECORD CHANGED")

elif cr==5:

y=input("enter the gender:")

quer="update teachers set gender='%s' where id=%d" %(y,tid)

c1.execute(quer)

d1.commit()

print("RECORD CHANGED")

elif cr==6:

ans1="yes"

while ans1=="yes":

y=int(input("enter the contact no:"))

quer1="select * from teachers where contact='%s'" %y

c1.execute(quer1)

if c1.rowcount>0:

print("DUPLICATE RECORD")

elif c1.rowcount==0:

ans1="no"

quer="update teachers set contact='%s' where id=%d" %(y,tid)

20
c1.execute(quer)

d1.commit()

print("RECORD CHANGED")

elif cr==7:

y=int(input("enter the salary:"))

quer="update teachers set sal=%d where id=%d" %(y,tid)

c1.execute(quer)

d1.commit()

print("RECORD CHANGED")

elif cr!=[1,2,3,4,5,6,7]:

print("INVAILD INPUT")

elif c1.rowcount==0:

print("NO RECORD FOUND TO CHANGE")

print("1. show all the records of teachers \n2. add records of a teacher \n3. search

records \n4. delete record \n5. Graphical representation \n6. Change values of records")

x=int(input("Enter the choice of no:"))

if x==1:

showallrecords()

21
elif x==2:

addrecords()

elif x==3:

search()

elif x==4:

delete()

elif x==5:

guestgr()

elif x==6:

changerecord()

elif x!=[1,2,3,4,5]:

print("\t\tINVAILD INPUT")

ans=input("want to continue:")

conn.commit()

22
23
MENU

24
SHOWING ALL RECORDS

25
ADDING RECORDS

26
SEARCH REORD

27
DELETING RECORD

GRAPHICAL REPRESENTATION
28
CHANGING VALUES OF RECORD

29
LIMITATION

30
1. PROGRAM HAS TO BE RUN EACH TIME AFTER PROCESSING
ONE PROCESS.
2. DELETED RECORD CAN’T BE RESTORED.
3. IT IS AN OFFLINE WORKING WORKING PROGRAM.
4. WE CAN’T RUN SQL CODING PROGRAM TWICE OR MORE.
5. IF YOU HAVE WRITTEN THE WRONG DATA, YOU CAN’T JUST
ERASE AND WRITE THEM CORRECTLY. YOU HAVE RE-RUN
THE PROGRAM FOR IT.
6.

31
BIBLIOGRAPHY
HELP TAKEN TO COMPLETE THIS PROJECT IS FROM:
 GUIDE MR. ANUP KUMAR SINGH
 MY FRIEND VIKAS KUMAR
 Google.co.in

32

You might also like