Вы находитесь на странице: 1из 5

#program on school management using python and My SQL

import mysql.connector as sqltor #importing mysql.connector


aq=sqltor.connect(host='localhost',user='root',passwd='',database='school')#establi
shing connection
cur=aq.cursor()#creating cursor
print("*********WELCOME TO SCHOOL MANAGMENT SYSTEM******")
while True:
print("1-Student managment\n2-Employee managment\n3-Fee managment\n4-End
program")#options in which one could be selected
b=int(input("Enter your choice 1-4-"))#choice of user

if b==1:
print("**********WELCOME TO STUDENT MANAGMENT SYSTEM*********")
while True:
print ('1-Display details\n2-New admission\n3-Search Student\n4-update
student details\n5-Issue Tc\n6-End program')
c=int(input('Enter your choice 1-6-'))#choice of user

if c==1:

cur=aq.cursor()
q="select * from student"#query to display complete details
cur.execute(q)#executing query
data=cur.fetchall()
for i in data:#loop for printing data in sequence
print (i)
aq.commit()

elif c==2:
if aq.is_connected():#checking connection
cur=aq.cursor()
tpl=tuple()#creating tuple
aa=str(input("Enter sname-")) ; tpl=tpl+(aa,)
ba=int(input("Enter admission no-")) ; tpl=tpl+(ba,)
ca=str(input("Enter DoB (yyyy/mm/dd)-")) ; tpl=tpl+(ca,)
da=str(input("Enter class-")) ; tpl=tpl+(da,)
ea=str(input("Enter house-")) ; tpl=tpl+(ea,)
q="insert into student values(%s,%s,%s,%s,%s)" #query
cur.execute(q,tpl) #executing query with tuple of inputs
aq.commit()
print("**SUCCESSFUL**")
else:
print("Sorry No Connection!!!!")

elif c==3 :
cur=aq.cursor()
tpl=tuple()
a=int(input("Enter admission no-"));tpl=tpl+(a,)
cur.execute('select *from student where admissionno=%s',tpl)
data=cur.fetchall()#fetching data
for i in data:
print (data) #printing result

elif c==4 :
cur=aq.cursor()
tpl=tuple()
b=str(input("Enter column to be updated(sname,Dob,class,house)
"));tpl=tpl+(b,)
c=str(input("Enter replacment-"));tpl=tpl+(c,)
a=int(input("enter admission no-"));tpl=tpl +(a,)
cur.execute("update student set %s=%s where admissionno=
%s",tpl)#query for update and execution of query
print("**SUCCESSFUL**")
aq.commit()

elif c==5 :
cur=aq.cursor()
tpl=tuple()
a=int(input("Enter admission no-"));tpl=tpl+(a,)
q="delete from student where admissionno=%s"
cur.execute(q,tpl)
print("**SUCCESSFUL**")
aq.commit()

elif c==6 :
print("Thank you for using STUDENT MANAGMENT SYSTEM")#end stu.mana
Break

else:
print("Enter correct choice 1-6")#if wrong choice

elif b==2:
print ("**********WELCOME TO EMPLOYEE MANAGMENT SYSTEM**********")
while True:
print("1-Display Details\n2-New Employee\n3-Search Employee\n4-Edit
Employee detail\n5-Remove Employee\n6-End Program")
c=int(input("Enter your choixe 1-6"))#users choice

if c==1:
cur=aq.cursor()
q="select *from Employee"#query
cur.execute(q)#execution of query
data=cur.fetchall()#fetching data
for i in data(): #loop for printing data in sequence
print (i)

elif c==2:
cur=aq.cursor()
print ("Enter details")
TPL=tuple()#new tuple
r=str(input("Ename"));TPL=TPL+(r,)
t=int(input("Eno"));TPL=TPL+(t,)
y=str(input("subject"));TPL=TPL+(y,)
u=str(input("DOB yyyy-mm-dd"));TPL=TPL+(u,) #DoB-date of birth
o=str(input("DOJ yyyy-mm-dd"));TPL=TPL+(o,) #DoJ-date of joining
p=str(input("Current Address"));TPL=TPL+(p,)
q="insert into Employee values(%s,%s,%s,%s,%s,%s)"#query
cur.execute(q,TPL)#execution of query
print("**SUCCESSFUL**")

elif c==3:
cur=aq.cursor()
TPL=tuple()
a=int(input("Enter Eno-"));TPL=TPL+(a,)#input by user
q="select *from Employee where Eno=%s"#query for selection
cur.execute(q,TPL)
data=cur.fetchall()
print(data)
aq.commit()

elif c==4:
cur=aq.cursor()
TPL=tuple()
b=input("Enter column(Ename,Eno,subject,DoB,DoJ,Address)");TPL=
TPL+(b,)
c=eval(input("Enter correct detail"));TPL=TPL+(c,)
a=int(input("Enter Eno-"));TPL=TPL+(a,)
q="update Employee set %s=%s where Eno=%s"
cur.execute(q,TPL)
print("**SUCCESSFUL**")

elif c==5:
cur=aq.cursor()
TPL=tuple ()
a=int(input("Enter Eno-"));TPL=TPL+(a,)
q="delete from Employee where Eno=%s"
cur.execute(q,TPL)
print("**SUCCESSFUL**")
aq.commit()

elif c==6:
print("Thank you for using EMPLOYEE MANAGMENT SYSTEM")#end of
employee management
Break

else:
print("Enter correct choice 1-6")#choose again

elif b==3:
print("**********WELCOME TO FEE MANAGMENT SYSTEM**********")
while True:
print("1-Display complete details\n2-Display students who has paid
fees\n3-Display student who hasn't paid fees\n4-Add record\n5-Search Student\n6-End
program")
c=int(input('Enter your choice 1-5'))

if c==1:
cur=aq.cursor()
q="select *from feemanag"
cur.execute(q)
data=cur.fetchall()
for i in data:
print(i)

elif c==2 :
cur=aq.cursor()
q="select *from feemanag where feestatus='paid'"
cur.execute(q)
data=cur.fetchall()
for i in data:
print(i)

elif c==3 :
cur=aq.cursor()
q="select *from feemanag where feestatus='unpaid'"
cur.execute(q)
data=cur.fetchall()
for i in data:
print(i)

elif c==4 :
cur=aq.cursor()
print("Enter details")
TPL=tuple()
a=int(input("Enter admission no-"));TPL=TPL+(a,)
b="paid";TPL=TPL+(b,)
c=str(input("Enter Date of payment [yyyy-mm-dd]��"));TPL=TPL+(c,)
l=int(input("Enter total fee-"));TPL=TPL+(l,)
q="insert into feemanag values(%s,%s,%s,%s)"
cur.execute(q,TPL)#executing query with tuple of outputs
print ("****SUCCESSFUL****")
aq.commit()

elif c==5 :
cur=aq.cursor()
TPL=tuple()
a=int(input("Enter admission no-"));TPL=TPL+(a,)
q="select *from feemanag where admissionno=%s"
cur.execute(q,TPL)
data=cur.fetchall()
for i in data:
print(i)

elif c==6 :
print("Thank you for using FEE MANAGMENT SYSTEM")
Break

else:
print("Enter correct choice 1-6")

elif b==4:
print("Thank you for using SCHOOL MANAGMENT SYSTEM")
break

else:
print("Enter correct choice 1-4")

Вам также может понравиться