Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Project On “Scholar Register”

By:

DBMS : MYSQL
HOST NAME : LOCAL HOST
USER : root
PASSWORD : root
DATABASE NAME : scholar
TABLES CREATED : scholar

import os

import platform

import mysql.connector

import pandas as pd

mydb=mysql.connector.connect(host="localhost",\
user="root",\

passwd="root",\

database="scholar")

mycursor=mydb.cursor()

def RegisterScholar():

L=[]

enroll=int(input("Enter the roll number(Max 5 Digits) : "))

L.append(enroll)

name=input("Enter the Name of scholar: ")

L.append(name)

age=int(input("Enter Age of scholar : "))

L.append(age)

city=input("Enter the City of the Scholar : ")

L.append(city)

classs=input("Enter the Class : ")

L.append(classs)

ph=input("Enter Phone number in Digits : ")

L.append(ph)

add=input("Enter Address of scholar : ")

L.append(add)

regfee=int(input("Enter the registration Fee : "))

L.append(regfee)

schol=(L)

sql="insert into scholar (enroll,sname,age,city,class,phone,address,regfee) values


(%s,%s,%s,%s,%s,%s,%s,%s)"

mycursor.execute(sql,schol)

mydb.commit()

def ScholarView():

print("Select the search criteria : ")

print("1. Enroll")

print("2. Name")
print("3. Age")

print("4. City")

print("5. phone")

print("6. Address")

print("7. All")

ch=int(input("Enter the choice : "))

if ch==1:

s=int(input("Enter enroll no : "))

rl=(s,)

sql="select * from scholar where enroll=%s"

mycursor.execute(sql,rl)

elif ch==2:

s=input("Enter Name : ")

rl=(s,)

sql="select * from scholar where sname=%s"

mycursor.execute(sql,rl)

elif ch==3:

s=int(input("Enter age : "))

rl=(s,)

sql="select * from scholar where age=%s"

mycursor.execute(sql,rl)

elif ch==4:

s=input("Enter City : ")

rl=(s,)

sql="select * from scholar where City=%s"

mycursor.execute(sql,rl)

elif ch==5:

s=input("Enter phone : ")

rl=(s,)

sql="select * from scholar where phone=%s"

mycursor.execute(sql,rl)
elif ch==6:

s=input("Enter address : ")

rl=(s,)

sql="select * from scholar where address=%s"

mycursor.execute(sql,rl)

elif ch==7:

sql="select * from scholar"

mycursor.execute(sql)

res=mycursor.fetchall()

print("The Students details are as follows : ")

print("(ROll, Name, Age, Class, City)")

for x in res:

print(x)

def SearchScholar():

print("Please enter the details to view the fee details :")

enroll=int(input("Enter the enroll number of the student whose fee is to be viewed : "))

sql="Select * from scholar where enroll=%s"

rl=(enroll,)

mycursor.execute(sql,rl)

res=mycursor.fetchall()

if res==None:

print("Record not Found . . . ")

return

print("The details of the students are : " )

for x in res:

print(x)

def RemoveScholar():

enroll=int(input("Enter the enroll number of the student to be deleted : "))


rl=(enroll,)

sql="Delete from scholar where enroll=%s"

mycursor.execute(sql,rl)

mydb.commit()

def MenuSet(): #Function For The Student Management System

print("Enter 1 : To Register Scholar")

print("Enter 2 : To View Scholar ")

print("Enter 3 : To Search Scholar ")

print("Enter 4 : To Remove Scholar")

try: #Using Exceptions For Validation

userInput = int(input("Please Select An Above Option: ")) #Will Take Input From User

except ValueError:

exit("\nHy! That's Not A Number") #Error Message

else:

print("\n") #Print New Line

if(userInput == 1):

RegisterScholar()

elif (userInput==2):

ScholarView()

elif (userInput==3):

SearchScholar()

elif (userInput==4):

RemoveScholar()

else:

print("Enter correct choice. . . ")

MenuSet()

def runAgain():
runAgn = input("\nwant To Run Again Y/n: ")

while(runAgn.lower() == 'y'):

if(platform.system() == "Windows"):

print(os.system('cls'))

else:

print(os.system('clear'))

MenuSet()

runAgn = input("\nwant To Run Again Y/n: ")

runAgain()
Register scholar
View scholar
Search scholar

Remove scholar

You might also like