Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

# PYTHON CODING

import mysql.connector as con

db=con.connect(host="localhost",user="root",passwd="0000",database="school_management_syste
m")

def csd(): #This function is for check student details

l=["1","2","3","4","5","6","7","8","9","10","11","12"]

you=input("\n Enter the class which you want to check(like-9/10/11/12) or press (a)for all ")

if you in l: #this occur if user asked specific detail

cur=db.cursor()

cur.execute(f"select * from s where class={you}")

for i in cur:

n=i[0]

c=i[1]

a=i[2]

ad=i[3]

d=i[4]

p=i[5]

print(f"name= {n} ,\t class= {c} ,\t admission_no= {a} ,\t address= {ad} ,\t date_of_birth= {d} ,\t
contact_no= {p} ")

elif you=="a": #this occur when user asked full detail

cur=db.cursor()

cur.execute("select * from s")

for i in cur:

n=i[0]

c=i[1]

a=i[2]
ad=i[3]

d=i[4]

p=i[5]

print(f"name= {n} ,\t class= {c} ,\t admission_no= {a} , \t address= {ad} ,\t date_of_birth= {d} ,\t
contact_no= {p} ")

else:

print("wrong input entered please choice one(9/10/11/12) or a for all")

csd()

main()

def ctd(): #This function is for check teacher details

print("\n")

cutr=db.cursor()

cutr.execute("select * from tea")

for i in cutr:

n=i[0]

post=i[1]

sub=i[2]

sal=i[3]

ad=i[4]

co=i[5]

ac=i[6]

print(f"name= {n} ,\t post= {post} ,\t subject= {sub} , \t salary= {sal} ,\t address= {ad} ,\t
contact_no= {co} ,\t account_no= {ac}")

main()

def rs(): #This function is for remove data of student

print("\n")
cur=db.cursor()

cur.execute("select * from s")

for i in cur:

n=i[0]

c=i[1]

a=i[2]

ad=i[3]

d=i[4]

p=i[5]

print(f"name= {n} ,\t class= {c} ,\t admission_no= {a} ,\t address= {ad} ,\t date_of_birth= {d} ,\t
contact_no= {p} ")

print("choice admission_no of student which you wanted to delete/remove")

delinp=input("Enter admission_no - ")

mycursor=db.cursor()

mycursor.execute(f"delete from s where admission_no={delinp}")

db.commit()

print("UPDATED TABLE")

cur=db.cursor()

cur.execute("select * from s")

for i in cur:

n=i[0]

c=i[1]

a=i[2]

ad=i[3]

d=i[4]

p=i[5]
print(f"name= {n} ,\t class= {c} ,\t admission_no= {a} ,\t address= {ad} ,\t date_of_birth= {d} ,\t
contact_no= {p} ")

main()

def ups(): #This function is for update the data of students

try:

print("\n Available information")

cur=db.cursor()

cur.execute("select * from s")

for i in cur:

n=i[0]

c=i[1]

a=i[2]

ad=i[3]

d=i[4]

p=i[5]

print(f"name= {n} ,\t class= {c} ,\t admission_no= {a} , \t address= {ad} ,\t date_of_birth= {d} ,\t
contact_no= {p} ")

admi=input("Choice admission_no fron above table in which you want to update data - ")

print("\n NOTE fill all the column correctly for successful update ")

n=input("Enter new name - ")

cl=input("Enter new class - ")

ad=input("Enter new address - ")

dob=input("Enter new date_of_birth in (YYYY-MM-DD) - ")

co=input("Enter new number - ")


mycursor =db.cursor()

mycursor.execute(f"update s set
name='{n}',class={cl},address='{ad}',date_of_birth='{dob}',contact={co} where admission_no
={admi}")

db.commit()

crs=db.cursor()

print("YOUR UPADATE DATA- ")

crs.execute(f"select * from s where admission_no={admi}")

for i in crs:

n=i[0]

c=i[1]

a=i[2]

ad=i[3]

d=i[4]

p=i[5]

print(f"name= {n} ,\t class= {c} ,\t admission_no= {a} , \t address= {ad} ,\t date_of_birth= {d} ,\t
contact_no= {p} ")

main()

except:

print("\n YOU ENTERED WRONG INPUT SO WE SEND YOU TO MAIN FUNCTION")

main()

def ads(): #This function is for adding student details

try:

mc=db.cursor()

n=input("\n Enter name - ")


c=input("Enter class (in number like 12) - ")

s=db.cursor() #THIS FOR SHOW EXISTING ADMISSION_NO

s.execute("select admission_no from s")

print("PLEASE TYPE admission_no OTHER THEN GIVEN NUMBERS")

for r in s:

print(r)

a=input("Enter admission_no - ")

ad=input("Enter address - ")

d=input("Enter date_of_birth in (YYYY-MM-DD) - ")

p=input("Enter contact_no - ")

mc.execute(f"insert into s(name,class,admission_no,address,date_of_birth,contact) values ('{n}' ,


{c} ,{a} ,'{ad}' ,'{d}' ,{p} )")

db.commit()

print("YOUR UPDATED DATA -")

cur=db.cursor()

cur.execute("select * from s")

for i in cur:

n=i[0]

c=i[1]

a=i[2]

ad=i[3]

d=i[4]

p=i[5]

print(f"name= {n} ,\t class= {c} ,\t admission_no = {a} ,\t address= {ad} ,\t date_of_birth= {d},\t
contact_no= {p} ")

main()
except:

print("\n YOUR INPUT IS WRONG YOU ARE SEND TO MAIN FUNCTION")

main()

def adtea(): #This function is for adding teacher details

try:

print("\n HERE IS ORIGINAL TEACHER DATA TABLE-")

cutr=db.cursor()

cutr.execute("select * from tea")

for i in cutr:

n=i[0]

post=i[1]

sub=i[2]

sal=i[3]

ad=i[4]

co=i[5]

ac=i[6]

print(f"name= {n} ,\t post= {post} ,\t subject= {sub} , \t salary= {sal} ,\t address= {ad} ,\t
contact_no= {co} ,\t account_no= {ac}")

n=input("Enter name - ")

post=input("Enter post - ")

sub=input("Enter subject - ")

sal=input("Enter salary - ")

ad=input("Enter address - ")

co=input("Enter contact_no - ")

ac=input("Enter account_no - ")


mc=db.cursor()

mc.execute(f"insert into tea(name,post,subject,salary,address,contact,account) values


('{n}' ,'{post}' ,'{sub}' ,{sal} ,'{ad}' ,{co} ,'{ac}' )")

db.commit()

print("UPDATED TABLE IS AS BELOW")

cutr=db.cursor()

cutr.execute("select * from tea")

for i in cutr:

n=i[0]

post=i[1]

sub=i[2]

sal=i[3]

ad=i[4]

co=i[5]

ac=i[6]

print(f"name= {n} ,\t post= {post} ,\t subject= {sub} , \t salary= {sal} ,\t address= {ad} ,\t
contact_no= {co} ,\t account_no= {ac}")

main()

except:

print("\n DUE TO THE WRONG INPUT YOU ARE SEND TO MAIN FUNCTION")

main()

def rtea(): #This function is for remove data of teacher

try:

print("\n HERE IS ORIGINAL TEACHER DATA TABLE-")

cutr=db.cursor()

cutr.execute("select * from tea")


for i in cutr:

n=i[0]

post=i[1]

sub=i[2]

sal=i[3]

ad=i[4]

co=i[5]

ac=i[6]

print(f"name= {n} ,\t post= {post} ,\t subject= {sub} , \t salary= {sal} ,\t address= {ad} ,\t
contact_no= {co} ,\t account_no= {ac}")

print("Select from above data the ( name ,post, subject) of teacher which you want to remove")

n=input("Enter name - ")

post=input("Enter post - ")

sub=input("Enter subject - ")

cool=db.cursor()

cool.execute(f"delete from tea where name='{n}' and post='{post}' and subject='{sub}' ")

db.commit()

print("YOUR UPDATED DATA IS - ")

mcutr=db.cursor()

mcutr.execute("select * from tea")

for i in mcutr:

n=i[0]

post=i[1]

sub=i[2]

sal=i[3]

ad=i[4]
co=i[5]

ac=i[6]

print(f"name= {n} ,\t post= {post} ,\t subject= {sub} , \t salary= {sal} ,\t address= {ad} ,\t
contact_no= {co} ,\t account_no= {ac}")

main()

except:

print("\n DUE TO THE WRONG INPUT YOU ARE SEND TO MAIN FUNCTION")

main()

def uptea(): #This function is for update the data of teachers

try:

print("HERE IS ORIGINAL TEACHER DATA TABLE-")

cutr=db.cursor()

cutr.execute("select * from tea")

for i in cutr:

n=i[0]

post=i[1]

sub=i[2]

sal=i[3]

ad=i[4]

co=i[5]

ac=i[6]

print(f"name= {n} ,\t post= {post} ,\t subject= {sub} , \t salary= {sal} ,\t address= {ad} ,\t
contact_no= {co} ,\t account_no= {ac}")

print("Select from above data the ( name ,post, subject) of teacher which you want to update")

n=input("Enter name - ")

post=input("Enter post - ")


sub=input("Enter subject - ")

print("\n NOTE fill all the column correctly for successful update ")

na=input("Enter new name - ")

po=input("Enter new post - ")

subj=input("Enter new subject - ")

salary=input("Enter new salary - ")

addre=input("Enter new address - ")

co=input("Enter new contact_no - ")

account=input("Enter new account - ")

mycursor =db.cursor()

mycursor.execute(f"update tea set


name='{na}',post='{po}',subject='{subj}',salary={salary},address='{addre}',contact={co},account='{acco
unt}' where name='{n}' and post='{post}' and subject='{sub}' ")

db.commit()

cros=db.cursor()

print("YOUR UPADATE DATA- ")

cros.execute(f"select * from tea where name='{na}' and post='{po}' and subject='{subj}' ")

for i in cros:

N=i[0]

ost=i[1]

Sub=i[2]

sal=i[3]

ad=i[4]

con=i[5]
ac=i[6]

print(f"name= {N} ,\t post= {ost} ,\t subject= {Sub} , \t salary= {sal} ,\t address= {ad} ,\t
contact_no= {con} ,\t account_no= {ac}")

main()

except:

print("YOU ENTERED WRONG INPUT SO WE SEND YOU TO MAIN FUNCTION")

main()

def fee(): #This function is used for updating fee

try:

print("\n Enter Admission number of stutent whose fees want to submit")

admi=input("ENTER ADMISSION NUMBER - ")

print("Last fee record - ")

cur=db.cursor()

cur.execute(f"select * from s where admission_no={admi}")

for i in cur:

n=i[0]

cl=i[1]

ad=i[2]

last_fee=i[6]

amount=i[7]

note=i[8]

print(f"name= {n} ,\t class= {cl} ,\t admission_no= {ad} , \t last_fee= {last_fee} ,\t
amount_of_last_fee= {amount} ,\t note= {note} ")

nlf=input("\nENTER NEW FEE SUBMISSION DATE IN (YYYY-MM-DD) - ")


na=input("ENTER NEW FEE AMOUNT - ")

nn=input("ENTER A NOTE IF YOU WANT OTHEWISE ENTER TO PROCEED - ")

mycursor =db.cursor()

mycursor.execute(f"update s set last_fee='{nlf}',amount_of_last_fee={na},note='{nn}' where


admission_no ={admi}")

db.commit()

crs=db.cursor()

print("YOUR UPADATED FEE DATA- ")

crs.execute(f"select * from s where admission_no={admi}")

for i in crs:

n=i[0]

c=i[1]

a=i[2]

last_fee=i[6]

amount=i[7]

note=i[8]

print(f"name= {n} ,\t class= {c} ,\t admission_no= {a} , \t last_fee= {last_fee} ,\t
amount_of_last_fee= {amount} ,\t note= {note} ")

main()

except:

print("\n YOU ENTER INCORRECT INPUT YOUR SEND TO MAIN FUNCTION ")

main()

def sal(): #This function is used for updating teachers salary

try:

print("HERE IS LAST UPDATED DATA-")


cutr=db.cursor()

cutr.execute("select * from tea")

for i in cutr:

n=i[0]

post=i[1]

sub=i[2]

sal=i[3]

ac=i[6]

lastsal=i[7]

amo=i[8]

nt=i[9]

print(f"name= {n} ,\t post= {post} ,\t subject= {sub} , \t salary= {sal} ,\t account_no= {ac} ,\t
last_salary_date={lastsal},\t last_salary_amount={amo},\t note={nt}")

print("Select from above data the ( name ,post, subject) of teacher in which you want to update
salary ")

n=input("Enter name - ")

post=input("Enter post - ")

sub=input("Enter subject - ")

newsald=input("ENTER NEW SALARY DATE(in YYYY-MM-DD) -")

amoun=input("ENTER NEW AMOUNT - ")

ne=input("ENTER A NOTE IF YOU WANT OTHEWISE ENTER TO PROCEED - ")

mycursor =db.cursor()

mycursor.execute(f"update tea set


last_salary='{newsald}',amount_of_last_salary={amoun},note='{ne}' where name='{n}' and
post='{post}' and subject='{sub}' ")
db.commit()

cros=db.cursor()

print("YOUR UPADATE SALARY DATA- ")

cros.execute(f"select * from tea where name='{n}' and post='{post}' and subject='{sub}' ")

for i in cros:

n=i[0]

post=i[1]

sub=i[2]

sal=i[3]

ac=i[6]

lastsal=i[7]

amo=i[8]

nt=i[9]

print(f"name= {n} ,\t post= {post} ,\t subject= {sub} , \t salary= {sal} ,\t account_no= {ac} ,\t
last_salary_date={lastsal},\t last_salary_amount={amo},\t note={nt}")

main()

except:

print("YOU ENTERED WRONG INPUT SO WE SEND YOU TO MAIN FUNCTION")

main()

def exit(): #This function is for exit

print('''

!!!!!!!!!!!! \t THANKS FOR USING ARE MANAGEMENT SYSTEM \t !!!!!!!!!

\t HAVE A NICE DAY \t

CREATED BY-"KULPREET SINGH"


''')

def main(): #This is a main function it connect all fuctionalities of program

print('''

\t \t \t \t 1.CHECK STUDENT DETAILS

\t \t \t \t 2.CHECK TEACHER DETAILS

\t \t \t \t 3.ADD STUDENT

\t \t \t \t 4.ADD TEACHER

\t \t \t \t 5.REMOVE STUDENT

\t \t \t \t 6.REMOVE TEACHER

\t \t \t \t 7.UPDATE STUDENT DETAILS

\t \t \t \t 8.UPDATE TEACHER DETAILS

\t \t \t \t 9.SUBMIT FEES

\t \t \t \t 10.PAY SALARY

\t \t \t \t 11.EXIT

''')

choice=input("Enter the task which you want perform type(1-11) - ")

if (choice=="1"):

csd()

elif(choice=="2"):

ctd()

elif(choice=="3"):

ads()

elif(choice=="4"):

adtea()

elif(choice=="5"):

rs()
elif(choice=="6"):

rtea()

elif(choice=="7"):

ups()

elif(choice=="8"):

uptea()

elif(choice=="9"):

fee()

elif(choice=="10"):

sal()

elif(choice=="11"):

exit()

else:

print("!!!!!!!!!!! \t\t WRONG INPUT ENTERED PLEASE CHOICE CORRECT NUMBER FROM(1-9) \t\
t !!!!!!!!!!!!!!!!!")

main()

x=True

cot=0

while x: #This piece of program asked password for login # THIS FOR SAFETY

check=input("ENTER YOUR DATABASE PASSWORD TO LOGIN - ")

if check=="0000":

print('''.................. \t\t WELCOME TO SCHOOL MANAGEMENT SYSTEM \t\t ...........''')

main()

x=False

else:

cot+=1

if cot==3:
x=False

print("!!!!!!!!!!!!!!!!!!! \t\t YOUR 3 ATTEMPT FINISHED \t\t !!!!!!!!!!!!!!!!!!!1")

else:

print('You have only',2-cot,"chance left")

You might also like