0% found this document useful (0 votes)
17 views12 pages

Sania

Uploaded by

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

Sania

Uploaded by

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

Table in mysql:-

Source code(In Python):-

# Checking mysql connectivity:-

import mysql.connector as c
con=c.connect(host='localhost',user='root',passwd='pagalhaitu',
database='school')
if con.is_connected():
print('Successfully connected to the database......')

# Creating a function to add student:-

def addstdn():
c=int(input("Enter Admission no.:"))
bn=input("Enter Student Name: ")
ba=input("Enter Class: ")
t=input("Enter City:")
d=input("Enter DOB:")
data=(c,bn,ba,t,d)
sql='insert into student values(%s,%s,%s,%s,%s);'
c=con.cursor()
c.execute(sql,data)
con.commit()
print("Student Added Successfully.......")
wait = input('Press enter to continue.....')
main()

# Creating a function for teachers:-

def tchr():
co=input('Enter teacher name:')
n=input('Enter class:')
r=input("Enter subject:")
d=input('Enter Date of joining:')
a="insert into teacher values(%s,%s,%s,%s);"
data=(co,n,r,d)
cursor=con.cursor()
cursor.execute(a,data)
con.commit()
print('Teacher data added successfully')
wait=input('Press enter to continue')
main()

# Creating a function for exams:-

def ex():
co=input('Enter subject:')
n=input('Enter exam date:')
r=input("Enter exam day:")
d=input('Enter class:')
a="insert into exams values(%s,%s,%s,%s);"
data=(co,n,r,d)
cursor=con.cursor()
cursor.execute(a,data)
con.commit()
print('Exam to be held for class:',d)
wait=input('Press enter to continue')
main()

# Creating a function for the deleting a student's record:-

def dstdn():
ac=int(input("Enter admission no: "))
a= "delete from student where admission_no=%s;"
data=(ac,)
c=con.cursor()
c.execute(a,data)
con.commit()
print("Student Record deleted successfully")
wait = input('Press enter to continue.....')
main()
# Creating a function to display student details:-

def dispstdn():
a="select * from student;"
c=con.cursor()
c.execute(a)
myresult=c.fetchall()
for i in myresult:
print("Admission no.:",i[0])
print("Student name:",i[1])
print("class:",i[2])
print("city:",i[3])
print("DOB",i[4])
wait = input('Press enter to continue.....')
main()

# Creating a function to give details of teacher:-

def dt():
a="select * from teacher;"
c=con.cursor()
c.execute(a)
myresult=c.fetchall()
for i in myresult:
print(myresult)
wait = input('Press enter to continue....')
main()

# Creating a function to give exam details:-

def dx():
a= 'select* from exams;'
c=con.cursor()
c.execute(a)
myresult=c.fetchall()
for i in myresult:
print(myresult)

wait = input('Press enter to continue.....')


main()

# School management system:-

def main():
print("""
1. ADD STUDENT
2. ADD TEACHER
3. SCHEDULE EXAM
4. DELETE STUDENT RECORD
5. DISPLAY STUDENT DETAILS
6. REPORT MENU
7. EXIT PROGRAM""")
choice=input("Enter Task No:......")
if(choice=='1'):
addstdn()
elif(choice=='2'):
tchr()
elif(choice=='3'):
ex()
elif(choice=='4'):
dstdn()
elif(choice=='5'):
dispstdn()
elif(choice=='6'):
print('''
REPORT MENU:
1. ISSUED BOOKS
2. RETURNED BOOKS
3. GO BACK TO MAIN MENU ''')
choice=input("Enter Task No:......")
if choice=='1':
dt()
elif choice=='2':
dx()
elif choice=='3':
main()
else:
print("PIease try again........")
main()
elif(choice=='7'):
print('Thank you and have a great day ahead
ahead............')
else:
print("Please try again.......")
main()

main()
Output in python:-
Output in sql:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy