Project
On
STUDENT management system
1|Page
TABLE STRUCTURE
.....................................................................................................................................
2|Page
Source code
.....................................................................................................................................
[Link]
import [Link] ## connect mysql to python
mydf = [Link](host='localhost', user='root', passwd='tiger')
def menu():
print("------------------------------------------------------------------------------------------------
-----------------")
print("---------------------------WELCOME TO STUDENT MANAGEMENT------------
--------------")
print("------------------------------------------------------------------------------------------------
-----------------")
c = 'y' or 'Y'
print("*"*100)
while c == 'y' or 'Y':
print("\t\t\t1. Add record")
print("\t\t\t2. Update record")
3|Page
print("\t\t\t3. Display record")
print("\t\t\t4. Delete record")
print("\t\t\t5. Search record")
print("\t\t\t6. Exiting")
print("*"*100)
choice = int(input("Enter your choice\t: "))
if choice == 1:
addrecord()
elif choice == 2:
update()
elif choice == 3:
display()
elif choice == 4:
delete()
elif choice == 5:
search()
elif choice == 6:
print("Exiting")
else:
print("wrong input")
c = input("Do you want to continue press y/n")
print('*'*100)
def createdb(): ##create database
try:
4|Page
mycursor = [Link]() ## execute sql queries
[Link]("create database student")
except:
print()
def createtable(): ##create table
mydf = [Link](host='localhost', user='root', passwd='tiger',
database='student')
try:
mycursor = [Link]()
sql = 'create table student(Registration_No int(20) primary key not null,\
Student_Name varchar(20) not null,\
Mother_Name varchar(15) ,\
Father_Name varchar(15),\
Gender varchar(2) not null,\
DOB date not null,\
Minority varchar(2),\
only_child varchar(1),\
Cast char(4),\
Adhar_no varchar(12) not null,\
Mobile_No varchar(10) not null,\
Fees decimal,\
Email_ID varchar(50))'
[Link](sql) ## fetching the result
[Link]()
except :
5|Page
print()
def addrecord(r1=None): ##add record
print("------------------------------------------------------------------------------------------------
--------")
print("---------------------------ADD STUDENT INFORMATION--------------------------
------")
print("------------------------------------------------------------------------------------------------
--------")
mydf = [Link](host='localhost', user='root', passwd='tiger',
database='student')
mycursor = [Link]()
print("*"*100)
r1=1
sql='Select*from student'
[Link](sql)
for x in mycursor:
r1=r1+1
print('Your registration number is:',r1)
s1=input("\t\t\tEnter the student name\t: ")
f1=input("\t\t\tEnter the father name\t: ").upper()
m1=input("\t\t\tEnter the mother name\t: ")
g1 = input('\t\t\tEnter the Gender\t: ')
6|Page
dob = input('\t\t\tEnter the date of birth(yyyy-mm-dd)\t: ')
m2 = input("\t\t\tEnter Minority-('Y' OR 'N') \t: ")
o1 = input("\t\t\tEnter only child-('Y' OR 'N')\t: ")
c1 = input("\t\t\tEnter cast-('OBC','GEN','SC','ST')\t: ")
a1 = input("\t\t\tEnter the Aadhar no. \t: ")
m3 = int(input("\t\t\tEnter the mobile no.\t: "))
f2 = int(input("\t\t\tEnter the fees\t: "))
e1 = input("\t\t\tEnter the email_id\t: ")
print("*"*100)
stud = (r1, s1, f1, m1, g1, dob, m2, o1, c1, a1, m3, f2, e1) ## convert into tuple
sql = 'insert into student value(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'
[Link](sql, stud)
[Link]()
print([Link], "Record added") ## count the row
def display(): ##display record
print("------------------------------------------------------------------------------------------------
------------")
print("---------------------------DISPLAYING STUDENT INFORMATION--------------
-----------")
print("------------------------------------------------------------------------------------------------
-------------")
mydf = [Link](host="localhost", user="root", passwd='tiger',
database='student')
mycursor = [Link]()
7|Page
print("show all records")
[Link]("select * from student")
print("RegNO\tStudent'sName\tFather'sName\tMother'sName")
y = [Link]() ## display all record
for x in y:
print(x[0], '\t', x[1], '\t', x[2],'\t', x[3])
def update(): ##update record
print("------------------------------------------------------------------------------------------------
-----------")
print("---------------------------UPDATE STUDENT INFORMATION---------------------
--------")
print("------------------------------------------------------------------------------------------------
-----------")
mydf = [Link](host="localhost", user="root", passwd='tiger',
database='student')
mycursor = [Link]()
print('*'*100)
print("\t\t\[Link] by student name")
print("\t\t\t2. update by father name")
print("\t\t\t3. update by mother name")
print("\t\t\t4. update by DOB")
print("\t\t\t5. update all")
print('*'*100)
c = int(input("enter your choice:"))
8|Page
if (c == 1):
mycursor = [Link]()
s1 = input("enter the student name\t:")
sql = 'select * from student where Student_Name=%s'
[Link](sql, (s1,))
print("RegNO\tStudent'sName\tFather'sName\tMother'sName\tDOB")
for x in mycursor:
print(x[0], '\t', x[1], '\t\t', x[2],'\t\t', x[3],'\t\t',x[4])
ch = input('Do you want to update record press y/n\t:')
if ch == 'y' or ch=='Y':
s2 = input("enter the new student name\t:")
sql = 'update student set Student_Name=%s where Student_Name =%s'
[Link](sql, (s2,s1))
[Link]()
print([Link], 'record update')
if (c == 2):
mycursor = [Link]()
f1 = input("enter the father name\t:")
sql = 'select * from student where Father_Name=%s'
[Link](sql, (f1,))
for x in mycursor:
print(x)
ch = input('Do you want to update record press y/n\t:')
if ch == 'y':
f3 = input("enter the new father name\t:")
sql = 'update student set Father_Name=%s where Father_Name=%s'
9|Page
[Link](sql, (f3,f1))
[Link]()
print([Link], 'record update')
if (c == 3):
mycursor = [Link]()
m1 = input("enter the mother name\t:")
sql = 'select * from student where Mother_Name=%s'
[Link](sql, (m1,))
for x in mycursor:
print(x)
ch = input('Do you want to update record press y/n\t:')
if ch == 'y':
m3 = input("enter the new mother name\t:")
sql = 'update student set Mother_Name=%s where Mother_Name=%s'
[Link](sql, (m3,m1))
[Link]()
print([Link], 'record update')
if (c == 4):
mycursor = [Link]()
d1 = input("enter the DOB\t:")
sql = 'select * from student where DOB=%s'
[Link](sql, (d1,))
for x in mycursor:
print(x)
ch = input('Do you want to update record press y/n\t:')
10 | P a g e
if ch == 'y':
d2 = input("enter the new DOB\t:")
sql = 'update student set DOB=%s where DOB=%s'
[Link](sql, (d2,d1))
[Link]()
print([Link], 'record update')
if (c == 5):
mycursor = [Link]()
r1 = int(input("enter the registration no.\t:"))
sql = 'select * from student where Registration_No=%s'
[Link](sql, (r1,))
for x in mycursor:
print(x)
ch = input('Do you want to update record press y/n\t:')
if ch == 'y':
s1 = input("\t\t\tEnter the new student name\t:")
f1 = input("\t\t\tEnter the new father name\t:")
m1 = input("\t\t\tEnter the new mother name")
g1 = input('\t\t\tEnter the new Gender\t:')
dob = input('\t\t\tEnter the new date of birth(yyyy-mm-dd)\t:')
m2 = input("\t\t\tEnter new Minority-('Y' OR 'N') \t:")
o1 = input("\t\t\tEnter new only child-('Y' OR 'N')\t:")
c1 = input("\t\t\tEnter new cast-('OBC','GEN','SC','ST')\t:")
a1 = input("\t\t\tEnter the new adhara no. \t:")
m3 = int(input("\t\t\tEnter the new mobile no.\t:"))
f2 = int(input("\t\t\tEnter the new fees\t:"))
11 | P a g e
e1 = input("\t\t\tEnter the new email_id\t:")
stud = ( s1, f1, m1, g1, dob, m2, o1, c1, a1, m3, f2, e1)
sql="update student set Reg_No=%s,\
Father_No=%s,\
Mother_Name=%s,\
Gender=%s,\
DOB=%s,\
Minority=%s,\
only_child =%s,\
Adhar_no =%s,\
Cast =%s,\
Mobile_No=%s,\
Fees=%s,\
Email_ID=%s where Registration_No=%s"
[Link](sql,(stud,))
[Link]()
print([Link], 'record update')
def delete(): ##delete record
print("------------------------------------------------------------------------------------------------
----------")
print("---------------------------DELETE STUDENT INFORMATION---------------------
--------")
print("------------------------------------------------------------------------------------------------
----------")
mydf = [Link](host="localhost", user="root", passwd='tiger',
12 | P a g e
database='student')
mycursor = [Link]()
print('*'*100)
print("\t\t\t1. Delete by Registration no")
print("\t\t\t2. Delete by student name")
print("\t\t\t3. Delete by father name")
print("\t\t\t4. Delete by mother name")
print("\t\t\t5. Delete by dob")
print("\t\t\t6. Delete all record")
print('*'*100)
ch = int(input("Enter your choice"))
if ch == 1:
mycursor = [Link]()
r1 = int(input('enter the registration No.-'))
ch = input("Do you want to delete record press y/n")
if ch == 'y':
[Link]('delete from student where Registration_No=%s', (r1,))
[Link]()
print([Link], 'record delete')
if (ch == 2):
mycursor = [Link]()
s1 = input('enter the student name-')
ch = input("Do you want to delete record press y/n")
if ch == 'y':
[Link]('delete from student where Student_Name = %s', (s1,))
[Link]()
13 | P a g e
print([Link], 'record delete')
if (ch == 3):
mycursor = [Link]()
f1 = input('enter the father name-')
ch = input("Do you want to delete record press y/n")
if ch == 'y':
[Link]('delete from student where Father_Name = %s', (f1,))
[Link]()
print([Link], 'record delete')
if (ch == 4):
mycursor = [Link]()
m1 = input('enter the mother name-')
ch = input("Do you want to delete record press y/n")
if ch == 'y':
[Link]('delete from student where Mother_Name = %s', (m1,))
[Link]()
print([Link], 'record delete')
if (ch == 5):
mycursor = [Link]()
d1 = input('enter the dob -')
ch = input("Do you want to delete record press y/n")
if ch == 'y':
[Link]('delete from student where DOB = %s', (d1,))
[Link]()
14 | P a g e
print([Link], 'record delete')
if (ch == 6):
mycursor = [Link]()
r1 = int(input('enter the registration no. -'))
ch = input("Do you want to delete record press y/n")
if ch == 'y':
[Link]('delete from student where Registration_No = %s', (r1,))
[Link]()
print([Link], 'record delete')
def search(): ##search record
print("------------------------------------------------------------------------------------------------
-----------")
print("---------------------------SEARCH STUDENT INFORMATION--------------------
---------")
print("------------------------------------------------------------------------------------------------
-----------")
mydf = [Link](host="localhost", user="root", passwd='tiger',
database='student')
mycursor = [Link]()
print('*'*100)
print("\t\t\t1. search by student name: ")
print("\t\t\t2. search by father name:")
print("\t\t\t3. search by mother name:")
print("\t\t\t4. search by registration no.:")
15 | P a g e
print("\t\t\t5. search by DOB")
print("\t\t\t6. search by all")
print('*'*100)
ch = int(input("enter your choice:"))
if (ch == 1):
mycursor = [Link]()
s1 = input("Enter the student name:")
[Link]("select * from student where Student_Name=%s", (s1,))
print([Link], 'record found.')
for x in mycursor:
print('RegNo.',x[0], '\nStudent_Name', x[1], '\nFather_Name', x[2],
'\nMothers_Name', x[3],'\nGender',x[4])
[Link]()
if (ch == 2):
mycursor = [Link]()
f1 = input("Enter the father name:")
[Link]('select * from student where Father_Name=%s', (f1,))
print([Link], 'record found.')
for x in mycursor:
print('RegNo.',x[0], '\nStudent_Name', x[1], '\nFather_Name', x[2],
'\nMothers_Name', x[3],'\nGender',x[4])
[Link]()
if (ch == 3):
16 | P a g e
mycursor = [Link]()
m1 = input("Enter the mother name:")
[Link]('select * from student where Mother_Name=%s', (m1,))
print([Link], 'record found.')
for x in mycursor:
print('RegNo.',x[0], '\nStudent_Name', x[1], '\nFather_Name', x[2],
'\nMothers_Name', x[3],'\nGender',x[4])
[Link]()
if (ch == 4):
mycursor = [Link]()
r1 = int(input("Enter the registration no.:"))
sql = 'select * from student where Registration_No=%s'
[Link](sql, (r1,))
print([Link], 'record found.')
for x in mycursor:
print('RegNo.',x[0], '\nStudent_Name', x[1], '\nFather_Name', x[2],
'\nMothers_Name', x[3],'\nGender',x[4])
[Link]()
if (ch == 5):
mycursor = [Link]()
d1 = input("Enter the dob:")
[Link]('select * from student where DOB=%s', (d1,))
print([Link], 'record found.')
17 | P a g e
for x in mycursor:
print('RegNo.',x[0], '\nStudent_Name', x[1], '\nFather_Name', x[2],
'\nMothers_Name', x[3],'\nGender',x[4])
[Link]()
if (ch == 6):
mycursor = [Link]()
sql = 'select * from student '
[Link](sql)
print([Link], 'record found.')
for x in mycursor:
print('RegNo.',x[0], '\nStudent_Name', x[1], '\nFather_Name', x[2],
'\nMothers_Name', x[3],'\nGender',x[4])
[Link]()
createdb()
createtable()
menu()
addrecord()
display()
update()
delete()
search()
18 | P a g e
OUTPUTs
…...............................................................
MENU PAGE
19 | P a g e
ADD RECORD
20 | P a g e
UPDATE RECORD
21 | P a g e
DISPLAY RECORD
SEARCH RECORD
22 | P a g e
DELETE RECORD
23 | P a g e
HARDWARE AND SOFTWARE REQUIREMENTS
[Link] SYSTEM : WINDOWS 7 AND ABOVE
II. PROCESSOR : PENTIUM (ANY) OR AMD
ATHALON(3800+- 4200+ DUALCORE)
III. MOTHERBOARD : 1.845 OR 915,995 FOR PENTIUM 0R MSI
K9MM-V VIAK8M800+8237R PLUS CHIPSET
FOR AMD ATHALON
IV. RAM : 512MB+
V. Hard disk : SATA 40 GB OR ABOVE
VI. CD/DVD r/w multi drive combo: (If back up required)
VII. FLOPPY DRIVE 1.44 MB : (If Backup required)
VIII. MONITOR 14.1 or 15 -17 inch
IX. Key board and mouse
X. Printer : (if print is required – [Hard copy])
SOFTWARE REQUIREMENTS:
I. Windows OS
II. Python
III. MySQL
24 | P a g e
BIBLIOGRAPHY
1. Computer science With Python - Class XI and XII By :
Sumita Arora
2. Websites-
For Python concepts –
[Link]
For MySQL concepts -
[Link]
***************
25 | P a g e