Anjeev Singh Academy

Python MySQL Project Student Admission Management System

Python MySQL Project for Class 12 / BCA / MCA/ B.Tech. / M.Tech.

Student Admission Management System

pythoninstall1.png

​Student Admission Management System is a project designed in Python Programming Language with MySQL. This project shows you the Python and MySQL Connectivity using the python mysql.connector package.

In this project, you can find the following operations like Insert, Update, View and Delete using Python and MySQL.

Helpful for students of class 12, BCA, MCA, B.Tech, M.Tech. and software trainees.

Project Details

The Main screen has several options to perform these tasks:

S. No.MenuPurpose of Menu Item
1.ADD NEW STUDENTTo add new students
2.VIEW STUDENTTo view all students
3.UPDATE STUDENTTo update the name of student
4.DELETE STUDENTTo delete student from table.
5.SEARCH STUDENTTo search student.
6.EXITTo close/exit the Application

Database Used in this Project:

An important aspect of system design is the design of data storage structures. To begin with, a logical model of data structure is developed first. A MySQL table is a storage container which allows to transfer the data quickly.

This software project maintains a database named School which contains the following table.

MYSQL Table:

The Student Admission System contains 1 MySQL files. The csv files and their structure are given below.

File: Student                                                                                           


Column Name                                          Type                              Size


RollNumber                                                                 Integer                     10

Name                                                                           VARCHAR                  30


Python Source Code:

import mysql.connector as sqlcon

import os


connection=sqlcon.connect(host="localhost", user="root", passwd="root", db="school")

mycursor=connection.cursor()

exit='n'    

while exit=='n':
    try: 
        os.system('cls')
        
        print("+-------------------+")
        print('| STUDENT ADMISSION |')
        print("+-------------------+")
        print('| [N]ew Admission   |')
        print('| [V]iew Student    |')
        print('| [U]pdate Student  |')
        print('| [D]elete Student  |')
        print('| [S]earch Record   |')
        print('| [E]XIT            |')
        print("+-------------------+")
        
        ch=input('YOUR Choice (N/V/U/D/S/E):').upper()
        
        if ch == 'N':
            os.system('cls')            
            print("NEW ADMISSION")
            choice='y'
            while choice=='y':
                rno=input('Enter Roll Number :: ')
                print()
                sname=input('Enter Name :: ')

                Qry = ("INSERT INTO class12 VALUES (%s, %s)")
                data = (rno,sname)

                try:
                   mycursor.execute(Qry,data)
                   print('RECORD INSERTED SUCCESSFULLY')
                   connection.commit()
                   
                except sqlcon.Error as err:
                    print("Error : ", err)
                
                choice=input('Insert more records (y/n)? ')
                if choice=='y':
                    os.system("cls")
                    continue
                
            

        elif ch == 'V':
            os.system('cls')
            print("VIEW STUDENT")
            
               
            query = ("""select * from class12""") 
                 
            mycursor.execute(query)

            data = mycursor.fetchall()

            
            print('+----------+--------------------+')
            print('| Roll No  | Student Name       |')
            print('+----------+--------------------+')
               
            count=0

            for(rno,name)in data:
                count += 1
                print('| %-8s | %-18s |' %(str(rno), name))
                #print(rno,name)    
            print('+----------+--------------------+')
            print('Total Records  :: ',count)
            
            
         
        elif ch == 'U':
            os.system('cls')
            print("UPDATE STUDENT")

            rno = int(input('enter the roll number to update name '))

            #Search Records
            Qry = ("""select * from class12 WHERE rollno = %s""") 
            data = (rno,) 

            mycursor.execute(Qry,data) 

            data = mycursor.fetchall()

            if mycursor.rowcount > 0:
                name=input('enter new name')
                Qry = ("""UPDATE class12 set name=%s WHERE rollno = %s""")
                data = (name,rno)

                mycursor.execute(Qry,data)

                print('RECORD UPDATED SUCCESSFULLY')

                connection.commit()
            else:
                print("Roll Number", rno, "not available...")
                
               
        elif ch == 'D':
            os.system('cls')
            print("DELETE STUDENT")

            rno=int(input('enter the roll number to delete '))

            Qry = ("DELETE FROM class12 WHERE rollno = %s")
            data = (rno,)

            mycursor.execute(Qry,data)

            print('RECORD DELETED SUCCESSFULLY')

            connection.commit()

        elif ch == 'S':
            os.system('cls')
            print("SEARCH STUDENT")        

            rno=int(input('Roll Number to Search :: '))

            Qry = ("""select * from class12 WHERE rollno = %s""") 
            data = (rno,) 

            mycursor.execute(Qry,data) 

            data = mycursor.fetchall()
            if mycursor.rowcount > 0:
                for(rno,name)in data:
                    print('Student Roll No  ',rno)
                    print('Student Name     ',name)
            else:
                print("Roll number", rno, "not available...")

        elif ch == 'E':
            os.system('cls')
            print("\n\t Thanks for using Student Management System...")
            print("\t+-----------------------------------------+")
            print("\t|   Created By - anjeevsingh              |")
            print("\t+-----------------------------------------+")
            break

        else:
            print('\t\t\t Error : Not a Valid Option ')
            exit=input('\t\t Do you wish to exit the program(y/n)')
            if exit=='n':
                continue

        input("Press enter key to continue...")
        
    except sqlcon.Error as err:
        print("Error : ", err)

Input-Output Screen:



Sorry! You cannot copy content of this page. Please contact, in case you want this content.

Scroll to Top