Share & Revise Any Time

Related Posts

Watch Tutorial of Class Management Project ( Recommended )

This project is covered in two parts ( Complete coding is given below )

1. MySQL coding 2. Python coding


import mysql.connector as a
con = a.connect(host="localhost",
              user="root",
              passwd="12345")
c = con.cursor()
sql1 = "create database class"
c.execute(sql1)
sql2 = "use class"
c.execute(sql2)
sql3 = "create table monitor (roll varchar(5),name varchar(50), month varchar(20))"
c.execute(sql3)
sql4 = "create table marks (roll varchar(5),name varchar(50), s1 int, s2 int, s3 int,total int,per float,term varchar(20))"
c.execute(sql4)
sql5 = "create table att(date varchar(10),abs varchar(500))"
c.execute(sql5)
sql6 = "create table students (roll varchar(5),name varchar(50), phone varchar(20),address varchar(50))"
c.execute(sql6)
con.commit()


import mysql.connector as a
con = a.connect(host="localhost",
              user="root",
              passwd="12345",
              database="class")

def monitor():
    o = int(input("1. Update Monitor    2. Check Monitor \n"))
    if o == 1:
        r = input("Enter Student Roll : ")
        n = input("Enter Student Name : ")
        c = input("Enter Month : ")
        data = (r,n,c)
        sql = 'insert into monitor values(%s,%s,%s)'
        c = con.cursor()
        c.execute(sql,data)
        con.commit()
        print("Data Entered Successfully")
        main()
    else:
        sql = "select * from monitor"
        c = con.cursor()
        c.execute(sql)
        d = c.fetchall()
        for i in d:
            print(i)
        main()

def marks():
    o = int(input("1. Update Marks    2. Check Marks \n"))
    if o == 1:
        r = input("Enter Student Roll : ")
        n = input("Enter Student Name : ")
        s1 = float(input("Subject 1 : "))
        s2 = float(input("Subject 2 : "))
        s3 = float(input("Subject 3 : "))
        t = s1 + s2 + s2
        per = (t/300)*100
        term = input("Enter Term : ")
        data = (r,n,s1,s2,s3,t,per,term)
        sql = 'insert into marks values(%s,%s,%s,%s,%s,%s,%s,%s)'
        c = con.cursor()
        c.execute(sql,data)
        con.commit()
        print("Data Entered Successfully")
        main()
    else:
        r = input("Enter Roll : ")
        t = input("Enter Term : ")
        sql = "select * from marks where roll = %s and term = %s "
        c = con.cursor()
        c.execute(sql,(r,t))
        for i in c:
            print(i)
        main()
      
def att():
    o = int(input("1. Update Attendance    2. Check Attendance \n"))
    if o == 1:
        d = input("Enter Date : ")
        ab = input("Enter Roll Numbers : ")
        data = (d,ab)
        sql = 'insert into att values(%s,%s)'
        c = con.cursor()
        c.execute(sql,data)
        con.commit()
        print("Data Entered Successfully")
        main()
    else:
        sql = "select * from att"
        c = con.cursor()
        c.execute(sql)
        d = c.fetchall()
        for i in d:
            print(i)
        main()

def students():
    o = int(input("1. Update Details    2. Check details \n"))
    if o == 1:
        r = input("Enter Student Roll : ")
        n = input("Enter Student Name : ")
        p = input("Enter Phone : ")
        a = input("Enter Address : ")
        data = (r,n,p,a)
        sql = 'insert into students values(%s,%s,%s,%s)'
        c = con.cursor()
        c.execute(sql,data)
        con.commit()
        print("Data Entered Successfully")
        main()
    else:
        sql = "select * from students"
        c = con.cursor()
        c.execute(sql)
        d = c.fetchall()
        for i in d:
            print(i)
        main()
          
def main():
    print("""
    1. Monitor
    2. Report Card
    3. Attendance
    4. Students
    """)
    choice = input("Enter Task No : ")
    while True:
        if (choice == '1'): 
            monitor()
        elif (choice=='2'): 
            marks() 
        elif (choice=='3'): 
            att() 
        elif (choice=='4'): 
            students()
        else: 
            print(" Wrong choice..........") 
main()

Share & Revise Any Time