Python Coding
Python Coding
##################################################################
#|---------------------------------------------------------------|
#|---------------------------------------------------------------|
##################################################################
import mysql.connector
myConnection=mysql.connector.connect(host="localhost",user='root',password
=passwd,database='Vidyalaya' )
if myConnection:
cursor=myConnection.cursor()
cursor.execute("COMMIT")
cursor.close()
return myConnection
else:
global userName
global password
global myConnection
myConnection=mysql.connector.connect(host="localhost",user='root',password='meandwho' ,database="tri
al2",)
if myConnection:
return myConnection
else:
myConnection.close()
def newStudent():
if myConnection:
cursor=myConnection.cursor()
cursor.execute(createTable)
sql="INSERT INTO
student(SNAME,FNAME,MNAME,PHONE,ADDRESS,SCLASS,SSECTION,SROLL_NO,SADMISSION_NO)
VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
values=(sname,fname,mname,phone,address ,sclass,ssection,sroll_no,sadmission_no)
cursor.execute(sql,values)
cursor.execute("COMMIT")
cursor.close()
else:
def displayStudent():
cursor=myConnection.cursor()
if myConnection:
data=cursor.fetchall()
print(data)
cursor.close()
else:
def updateStudent():
cursor=myConnection.cursor()
if myConnection:
cursor.execute(sql,(admission_no,))
data=cursor.fetchall()
if data:
if choice==1:
cursor.execute(sql,(name,admission_no))
cursor.execute("COMMIT")
print("NAME UPDATED...")
elif choice==2:
cursor.execute("COMMIT")
elif choice==3:
cursor.execute(sql,(mname,admission_no))
cursor.execute("COMMIT")
elif choice==4:
cursor.execute(sql,(cn,admission_no))
cursor.execute("COMMIT")
elif choice==5:
cursor.execute(sql,(adrs,admission_no))
cursor.execute("COMMIT")
print("ADDRESS UPDATED...")
elif choice==6:
cursor.execute(sql,(std,admission_no))
cursor.execute("COMMIT")
print("CLASS UPDATED...")
elif choice==7:
cursor.execute(sql,(sec,admission_no))
cursor.execute("COMMIT")
print("SECTION UPDATED...")
elif choice==8:
cursor.execute(sql,(roll_no,admission_no))
cursor.execute("COMMIT")
print("ROLL NO UPDATED...")
else:
cursor.close()
else:
def marksStudent () :
if myConnection:
cursor=myConnection.cursor()
cursor.execute(createTable)
admission_no=input("\nENTER ADMISSION NO OF THE STUDENT :")
average = total/6
sql="INSERT INTO
MARKS(SADMISSION_NO,HINDI,ENGLISH,MATH,SCIENCE,SOCIAL,COMPUTER,TOTAL,AVERAGE) VALUES(%s,
%s,%s,%s,%s,%s,%s,%s,%s)"
cursor.execute(sql,values)
cursor.execute("COMMIT")
cursor.close()
else:
def reportCardAllStudent () :
cursor=myConnection.cursor()
if myConnection:
data=cursor.fetchall()
print(data)
cursor.close()
else:
def reportCardOneStudent():
cursor=myConnection.cursor()
if myConnection:
cursor=myConnection.cursor()
cursor.execute(sql,(admission_no,))
data=cursor.fetchall()
if data:
print(data)
else:
cursor.close()
else:
def feeStudent () :
if myConnection:
cursor=myConnection.cursor()
cursor.execute(createTable)
sql="INSERT INTO
FEES(SADMISSION_NO,MONTH,TUTION_FEES,VVN,COMPUTER_FEES,MUSIC_FEES,TOTAL) VALUES(%s,%s,
%s,%s,%s,%s,%s)"
values=(admission_no,month,tutionfee,vvn,computerfee,musicfee,total)
cursor.execute(sql,values)
cursor.execute("COMMIT")
cursor.close()
else:
def feeReceiptAllStudent():
cursor=myConnection.cursor()
if myConnection:
data=cursor.fetchall()
print(data)
cursor.close()
else:
cursor=myConnection.cursor()
if myConnection:
cursor=myConnection.cursor()
cursor.execute(sql,(admission_no,))
data=cursor.fetchall()
if data:
print(data)
else:
cursor.close()
else:
def transferStudent():
cursor=myConnection.cursor()
if myConnection:
cursor=myConnection.cursor()
cursor.execute(sql,(admission_no,))
data=cursor.fetchall()
if data:
cursor.execute(sql,(admission_no,))
cursor.execute("COMMIT")
else:
cursor.close()
else:
def helpMe():
print("\nPlease visit the offcial website Of Vidyalaya to download the mannual !!!")
print("\n#################################################################")
print("\n|---------------------------------------------------------------|")
print("\n|---------------------------------------------------------------|")
print("\n#################################################################")
passwd=input("Enter Password:")
if myConnection:
MYSQLconnection ()
while(1):
print("\n |-----------------------------------------------------------|")
print(" |-----------------------------------------------------------|")
print(" |-----------------------------------------------------------|")
if choice==1:
newStudent()
elif choice==2:
displayStudent()
elif choice==3:
updateStudent()
elif choice==4:
transferStudent()
elif choice==5:
marksStudent()
elif choice==6:
reportCardAllStudent()
elif choice==7:
reportCardOneStudent()
elif choice==8:
feeStudent()
elif choice==9:
feeReceiptAllStudent()
elif choice==10:
feeReceiptOneStudent()
elif choice==11:
myConnection.close()
print("\nDHANYAWAAD...")
break
elif choice==0:
helpMe()
else:
print("Sorry ,maybe you are giving wrong input, please try again!!! ")
else: