Professional Documents
Culture Documents
KATHMANDU
A Project Report
On
For
11208
Amit Dave
CERTIFICATE
This is to certify that Pranav Pratap Singh, a student of Class XI B has
successfully completed the project on “Student Details Management
System” mentioned under the guidance of Sh. Amit Dave (PGT
Comp.Sc.) during the year 2018-19 in partial fulfillment of
Informatics Practices Practical Examination.
Amit Dave
Subject Teacher
R. SANKAR
PRINCIPAL
ACKNOWLEDGEMENT
History of Python
Python was developed by Guido van Rossum in the late eighties and
early nineties at the National Research Institute for Mathematics
and Computer Science in the Netherlands.
Python is derived from many other languages, including ABC,
Modula-3, C, C++, Algol-68, SmallTalk, and Unix shell and other
scripting languages.
Python is copyrighted. Like Perl, Python source code is now available
under the GNU General Public License (GPL).
Python is now maintained by a core development team at the
institute, although Guido van Rossum still holds a vital role in
directing its progress.
Python Features
Python's features include −
Easy-to-learn − Python has few keywords, simple structure, and a
clearly defined syntax. This allows the student to pick up the language
quickly.
Easy-to-read − Python code is more clearly defined and visible to the
eyes.
Easy-to-maintain − Python's source code is fairly easy-to-maintain.
A broad standard library − Python's bulk of the library is very portable
and cross-platform compatible on UNIX, Windows, and Macintosh.
Interactive Mode − Python has support for an interactive mode which
allows interactive testing and debugging of snippets of code.
Portable − Python can run on a wide variety of hardware platforms and
has the same interface on all platforms.
Extendable − You can add low-level modules to the Python interpreter.
These modules enable programmers to add to or customize their tools
to be more efficient.
Databases − Python provides interfaces to all major commercial
databases.
GUI Programming − Python supports GUI applications that can be
created and ported to many system calls, libraries and windows
systems, such as Windows MFC, Macintosh, and the X Window system
of Unix.
Scalable − Python provides a better structure and support for large
programs than shell scripting.
Apart from the above-mentioned features, Python has a big list of
good features, few are listed below −
It supports functional and structured programming methods as well as
OOP.
It can be used as a scripting language or can be compiled to byte-code
for building large applications.
It provides very high-level dynamic data types and supports dynamic
type checking.
It supports automatic garbage collection.
It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
ALGORITHM
main_page.py
1. Start
2. Import the tkinter module
3. Import the module sub(self-created module containing linkage with
database)
4. Create the main window(container)
5. Define the commands required in the program:
a) view_command e)update_command
b) search_command f) delete_command
c) add_command g)clear_command
d) get_selected_row
6. Create a table like form using grid method and label each row
7. Create entry box in each row specifying the type of data to be
entered
8. Create buttons for different commands required in the program and
link them to their respective functions defined earlier.
9. Create a list box to display necessary details.
10. Stop
sub.py
1. Start
2. Import sqlite3
3. Define the following functions to create and make changes in the
database
a) create-to create the database if not present
b) viewwall- to display all the records of the database
c) search- to search the required record in the database
d) add- to add new records in the database
e) update- to update the fields of existing records
f) delete- to delete the required records from the database
4. Stop
CODE
(main_page.py)
#Simple student details management system
# Developed By: Pranav Pratap Singh & Shruti Thapa (Class-11B)
def view_command():
lb.delete(0,END)
for row in sub.viewall():
lb.insert(END,row)
def search_command():
lb.delete(0,END)
for row in
sub.search(name=name.get(),fname=fname.get(),mname=mname.get(),dob=d
ob.get(),contact=contact.get(),email=email.get(),admno=admno.get()):
lb.insert(END,row)
def add_command():
sub.add(name.get(),fname.get(),mname.get(),dob.get(),contact.get(),email.get
(),admno.get())
lb.delete(0,END)
lb.insert(END,name.get(),fname.get(),mname.get(),dob.get(),contact.get(),ema
il.get(),admno.get())
def get_selected_row(event):
try:
global selected_tuple
index=lb.curselection()[0]
selected_tuple = lb.get(index)
e1.delete(0,END)
e1.insert(END,selected_tuple[1])
e2.delete(0,END)
e2.insert(END,selected_tuple[2])
e3.delete(0,END)
e3.insert(END,selected_tuple[3])
e4.delete(0,END)
e4.insert(END,selected_tuple[4])
e5.delete(0,END)
e5.insert(END,selected_tuple[5])
e6.delete(0,END)
e6.insert(END,selected_tuple[6])
e7.delete(0,END)
e7.insert(END,selected_tuple[7])
except IndexError:
pass
def update_command():
sub.update(selected_tuple[0],name=name.get(),fname=fname.get(),mname=
mname.get(),dob=dob.get(),contact=contact.get(),email=email.get(),admno=a
dmno.get())
view_command()
def delete_command():
sub.delete(selected_tuple[0])
view_command()
def clear_command():
lb.delete(0,END)
e1.delete(0,END)
e2.delete(0,END)
e3.delete(0,END)
e4.delete(0,END)
e5.delete(0,END)
e6.delete(0,END)
e7.delete(0,END)
l1 = Label(window,text="Full Name")
l1.grid(row=0,column=0,columnspan=2)
l2 = Label(window,text="Father's Name")
l2.grid(row=1,column=0,columnspan=2)
l3 = Label(window,text="Mother's Name")
l3.grid(row=2,column=0,columnspan=2)
l4 = Label(window,text="D.O.B(DD/MM/YYYY)")
l4.grid(row=3,column=0,columnspan=2)
l5 = Label(window,text="Contact No.")
l5.grid(row=4,column=0,columnspan=2)
l6 = Label(window,text="Email")
l6.grid(row=5,column=0,columnspan=2)
l7 = Label(window,text="Admn No.")
l7.grid(row=6,column=0,columnspan=2)
name=StringVar()
e1 = Entry(window,textvariable=name,width=50)
e1.grid(row=0,column=0,columnspan=10)
fname=StringVar()
e2 = Entry(window,textvariable=fname,width=50)
e2.grid(row=1,column=0,columnspan=10)
mname=StringVar()
e3 = Entry(window,textvariable=mname,width=50)
e3.grid(row=2,column=0,columnspan=10)
dob=StringVar()
e4 = Entry(window,textvariable=dob,width=50)
e4.grid(row=3,column=0,columnspan=10)
contact=StringVar()
e5 = Entry(window,textvariable=contact,width=50)
e5.grid(row=4,column=0,columnspan=10)
email=StringVar()
e6 = Entry(window,textvariable=email,width=50)
e6.grid(row=5,column=0,columnspan=10)
admno=IntVar()
e7 = Entry(window,textvariable=admno,width=50)
e7.grid(row=6,column=0,columnspan=10)
b1 = Button(window,text="Add",width=12,command=add_command)
b1.grid(row=7,column=0)
b2 = Button(window,text="Update",width=12,command=update_command)
b2.grid(row=7,column=1)
b3 = Button(window,text="Search",width=12,command=search_command)
b3.grid(row=7,column=2)
b4 = Button(window,text="View All",width=12,command=view_command)
b4.grid(row=7,column=3)
b5 = Button(window,text="Delete",width=12,command=delete_command)
b5.grid(row=7,column=4)
b6 = Button(window,text="Exit",width=12,command=window.destroy)
b6.grid(row=7,column=5)
b7 = Button(window,text="Clear All",width=12,command=clear_command)
b7.grid(row=0,column=5)
lb=Listbox(window,height=25,width=110)
lb.grid(row=8,column=0,columnspan=6)
sb=Scrollbar(window)
sb.grid(row=8,column=6,rowspan=6)
lb.configure(yscrollcommand=sb.set)
sb.configure(command=lb.yview)
lb.bind('<<ListboxSelect>>',get_selected_row)
window.mainloop()
(sub.py)
import sqlite3
def create():
con = sqlite3.connect("sub.db")
cur = con.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS account(id INTEGER PRIMARY
KEY,name TEXT,fname TEXT,mname TEXT,dob TEXT, contact TEXT,email
TEXT,admno INTEGER)")
con.commit()
con.close()
def viewall():
con = sqlite3.connect("sub.db")
cur = con.cursor()
cur.execute("SELECT * FROM account")
rows = cur.fetchall()
con.close()
return rows
def
search(name="",fname="",mname="",dob="",contact="",email="",admno=""):
con = sqlite3.connect("sub.db")
cur = con.cursor()
cur.execute("SELECT * FROM account WHERE name=? OR fname=? OR
mname=? OR dob=? OR contact=? OR email=? OR admno=?",
(name,fname,mname,dob,contact,email,admno))
rows = cur.fetchall()
con.close()
return rows
def add(name,fname,mname,dob,contact,email,admno):
con = sqlite3.connect("sub.db")
cur = con.cursor()
cur.execute("INSERT INTO account VALUES(NULL,?,?,?,?,?,?,?)",
(name,fname,mname,dob,contact,email,admno))
con.commit()
con.close()
def update(id,name,fname,mname,dob,contact,email,admno):
con = sqlite3.connect("sub.db")
cur = con.cursor()
cur.execute("UPDATE account SET
name=?,fname=?,mname=?,dob=?,contact=?,email=?,admno=? WHERE id=?",
(name,fname,mname,dob,contact,email,admno,id))
con.commit()
con.close()
def delete(id):
con = sqlite3.connect("sub.db")
cur = con.cursor()
cur.execute("DELETE FROM account WHERE id=?",(id,))
con.commit()
con.close()
create()
OUTPUT SCREEN
1. Initial page
2. Add details
3. View all records
4. Record to be updated
5. Updated record
6. Search results
BIBLIOGRAPHY
1. https://en.wikibooks.org
2. https://www.tutorialspoint.com
3. https://pythonspot.com/python-database-
programming-sqlite-tutorial/
4. https://www.w3schools.com
5. https://www.youtube.com