0% found this document useful (0 votes)
17 views

School Project - Py

Uploaded by

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

School Project - Py

Uploaded by

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

#source code

print("******school mangement********")
#creating database
import mysql.connector as m
mydb=m.connect(host="localhost",username="root",passwd="123456",database="pyschool"
)
if mydb.is_connected():
print("connected")
else:
print("not")
mycursor=mydb.cursor()
#creating required tables
mycursor.execute("create table if not exists pystudentt(name varchar(20)not
null,class varchar(10) not null,roll_no integer(11),gender varchar(10))")
mycursor.execute("create table if not exists pystaff(name varchar(50),gender
varchar(10),subject varchar(12),salary integer)")
mydb.commit()
while(True):
print("1=enter data for new student")
print("2=enter data for new staff data")
print("3=search student data")
print("4=search staff data")
print("5=remove student record")
print("6=remove staff record")
print("7=exit")
ch=int(input("enter your choice:"))
#procedure for entering a new student record
if(ch==1):
print("all information prompted are mandatory to be filled")
name=input("enter name")
classs=input("enter class")
roll_no=int(input("enter roll no"))
gender=input("enter gender")
sql="insert into pystudentt
values('{}','{}','{}],'{}')".format(name,classs,roll_no,gender)
mycursor.execute(sql)
mydb.commit()
print("student record has been saved successfully")
elif(ch==2):
sname=input("enter staff menber name:")
gender=input("enter gender:")
dep=input("enter department or subject:")
sal=int(input("enter salary of new staff:"))
mycursor.execute("insert into pystaff
values('"+sname+","+gender+","+dep+","+sal+"')")
mydb.commit()
print("staff record has been successfully saved!!!")
elif(ch==3):
roll_no=int(input("enter student rollno:"))
mycursor.execute("select*from pystudent where roll_no='"+roll_no+"'")
for i in mycursor:
name,classs,roll_no,gender=i
print("fName:-{name}")
print("fClass:-{classs}")
print("fRoll number:-{roll_no}")
print("fGender :-{gender}")
elif(ch==4):
name=int(input("enter name:"))
mycursor.execute("select*from pystaff where name='"+name+"'")
for i in mycursor:
name,gender,dep,sal=i
print("fName:-{name}")
print("fgender:-{gender}")
print("fDepartment:-{dep}")
print("fsalary:={sal}")
elif(ch==5):
r_no=int(input("enter rollno:"))
mycursor.execute("delete from pystudent where roll_no='"+r_no+"'")
mydb.commit()
print("successfully deleted student record")
elif(ch==6):
name=input("enter name of the staff member:")
mycursor.execute("delete from pystaff where name='"+name+"'")
mydb.commit()
print("staff record successfully deleted")
elif(ch==7):
break

You might also like