Comp Sci Anuu
Comp Sci Anuu
(SESSION:2023-24)
1
INDEX
CONTENT
Acknowledgement
Certificate
Introduction
Requirements
Program Code
Output
Conclusion
Analysis
Bibliography
2
ACKNOWLEDGEMENT
It gives me a great pleasure to express my gratitude towards our ComputerScience
teacher Mr. Dillip Ingle and Principal Mr. Vijay Kumar Garg for Their guidance,
support, and encouragement throughout the duration of the project. Without Their
motivation and help the successful completion ofthis project would not have been
possible.
I am also grateful to my classmates who engaged in meaningful discussions, shared
ideas, and provided constructive feedback during the brainstorming and
development stages of this project.
Further, would like to extend my appreciation to my friends and family for their
support and encouragement.
3
CERTIFICATE
This is to certify that Kumari Anamika of class Xll – A has worked
successfully under the supervision of Mr. Dillip Ingle during academic year
2023–24 on the project “Library Management System” as per the guidelines
issued by Central Board of Secondary Education (CBSE).
Signature of Principal :
4
INTRODUCTION
‘Library Management System’ is basically aimed to
provide a library manager which will help the user to keep a
track of the books being issued, returned and which are
added and being removed from the library.
The user can use the ‘Library Management System’ to
insert and delete a book. The user has to give necessary
details such as Book id, Name of the book, Author of the
book etc. to add it in the library. It also provides the user to
mark the books which are being returned to the library.
There is also an option to change the name of the person
who has issued the book. Books can also be deleted.
The books are stored in My-SQL as a table with necessary
details.
Whenever a book is edited or deleted, the changes are
simultaneously carried out in My-SQL.
5
REQUIREMENTs
❖ HARDWARE REQUIRED
➢Printer: To print the required documents of the project
❖ SOFTWARE REQUIRED
➢Operating system : Windows 10
➢IDLE(Python 3.8, 64-bit), for execution of program
➢MS-Word, for presentation of output.
6
PROGRAM CODE
from tkinter import *
from PIL import ImageTk,Image
import pymysql
from tkinter import messagebox
#----------------------------Main Window-------------------------------
mypass = "tiger"
mydatabase="Csproject"
con =
pymysql.connect(host="localhost",user="root",password=mypas
s,database=mydatabase)
cur = con.cursor()
same=True
n=1
7
# Adding a background image
background_image =Image.open("lib.jpeg")
[imageSizeWidth, imageSizeHeight] = background_image.size
newImageSizeWidth = int(imageSizeWidth*n)
if same:
newImageSizeHeight = int(imageSizeHeight*n)
else:
newImageSizeHeight = int(imageSizeHeight/n)
background_image =
background_image.resize((newImageSizeWidth,newImageSize
Height),Image.Resampling.LANCZOS)
img = ImageTk.PhotoImage(background_image)
Canvas1 = Canvas(root)
Canvas1.create_image(300,340,image = img)
Canvas1.config(bg="white",width = newImageSizeWidth, height
= newImageSizeHeight)
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.2,rely=0.1,relwidth=0.6,relheight=0.
16)
root.mainloop()
9
#-------------------------------Add books--------------------------------
def bookRegister():
bid = bookInfo1.get()
title = bookInfo2.get()
author = bookInfo3.get()
status = bookInfo4.get()
status = status.lower()
print(bid)
print(title)
print(author)
print(status)
root.destroy()
def addBook():
10
global
bookInfo1,bookInfo2,bookInfo3,bookInfo4,Canvas1,con,cur,book
Table,root
con =
pymysql.connect(host="localhost",user="root",password="tiger",
database="Csproject")
cur = con.cursor()
Canvas1 = Canvas(root)
Canvas1.config(bg="#ff6e40")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0
.13)
11
headingLabel = Label(headingFrame1, text="Add Books",
bg='black', fg='white', font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)
labelFrame = Frame(root,bg='black')
labelFrame.place(relx=0.1,rely=0.4,relwidth=0.8,relheight=0.4)
# Book ID
lb1 = Label(labelFrame,text="Book ID : ", bg='black',
fg='white')
lb1.place(relx=0.05,rely=0.2, relheight=0.08)
bookInfo1 = Entry(labelFrame)
bookInfo1.place(relx=0.3,rely=0.2, relwidth=0.62,
relheight=0.08)
# Title
lb2 = Label(labelFrame,text="Title : ", bg='black', fg='white')
lb2.place(relx=0.05,rely=0.35, relheight=0.08)
bookInfo2 = Entry(labelFrame)
bookInfo2.place(relx=0.3,rely=0.35, relwidth=0.62,
relheight=0.08)
# Book Author
lb3 = Label(labelFrame,text="Author : ", bg='black', fg='white')
lb3.place(relx=0.05,rely=0.50, relheight=0.08)
12
bookInfo3 = Entry(labelFrame)
bookInfo3.place(relx=0.3,rely=0.50, relwidth=0.62,
relheight=0.08)
# Book Status
lb4 = Label(labelFrame,text="Status(Avail/issued) : ",
bg='black', fg='white')
lb4.place(relx=0.05,rely=0.65, relheight=0.08)
bookInfo4 = Entry(labelFrame)
bookInfo4.place(relx=0.3,rely=0.65, relwidth=0.62,
relheight=0.08)
#Submit Button
SubmitBtn = Button(root,text="SUBMIT",bg='#d1ccc0',
fg='black',command=bookRegister)
SubmitBtn.place(relx=0.28,rely=0.9,
relwidth=0.18,relheight=0.08)
root.mainloop()
13
#-------------------------------View Books-------------------------------
con =
pymysql.connect(host="localhost",user="root",password="tiger",
database="Csproject")
cur = con.cursor()
bookTable = "books"
def View():
Canvas1 = Canvas(root)
Canvas1.config(bg="#12a4d9")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0
.13)
14
headingLabel = Label(headingFrame1, text="View Books",
bg='black', fg='white', font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)
labelFrame = Frame(root,bg='black')
labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.5)
y = 0.25
Label(labelFrame, text="%-10s%-40s%-30s%-
20s"%('BID','Title','Author','Status'),bg='black',fg='white').place(r
elx=0.07,rely=0.1)
Label(labelFrame, text="---------------------------------------------
-------------------------------
",bg='black',fg='white').place(relx=0.05,rely=0.2)
getBooks = "select * from "+bookTable
try:
cur.execute(getBooks)
con.commit()
for i in cur:
Label(labelFrame, text="%-10s%-30s%-30s%-
20s"%(i[0],i[1],i[2],i[3]),bg='black',fg='white').place(relx=0.07,rely
=y)
y += 0.1
except:
messagebox.showinfo("Failed to fetch files from database")
#------------------------------Deleting Books----------------------------
con =
pymysql.connect(host="localhost",user="root",password="tiger",
database="Csproject")
cur = con.cursor()
issueTable = "books_issued"
bookTable = "books"
def deleteBook():
bid = bookInfo1.get()
print(bid)
bookInfo1.delete(0, END)
root.destroy()
def delete():
global
bookInfo1,bookInfo2,bookInfo3,bookInfo4,Canvas1,con,cur,book
Table,root
Canvas1 = Canvas(root)
Canvas1.config(bg="#006B38")
17
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0
.13)
labelFrame = Frame(root,bg='black')
labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.5)
# Book ID to Delete
lb2 = Label(labelFrame,text="Book ID : ", bg='black',
fg='white')
lb2.place(relx=0.05,rely=0.5)
bookInfo1 = Entry(labelFrame)
bookInfo1.place(relx=0.3,rely=0.5, relwidth=0.62)
#Submit Button
SubmitBtn = Button(root,text="SUBMIT",bg='#d1ccc0',
fg='black',command=deleteBook)
SubmitBtn.place(relx=0.28,rely=0.9,
relwidth=0.18,relheight=0.08)
18
quitBtn = Button(root,text="Quit",bg='#f7f1e3', fg='black',
command=root.destroy)
quitBtn.place(relx=0.53,rely=0.9,
relwidth=0.18,relheight=0.08)
root.mainloop()
#-------------------------------IssueBook--------------------------------
con =
pymysql.connect(host="localhost",user="root",password="tiger",
database="Csproject")
cur = con.cursor()
issueTable = "books_issued"
bookTable = "books"
19
allBid = []
def issue():
global
issueBtn,labelFrame,lb1,inf1,inf2,quitBtn,root,Canvas1,status
bid = inf1.get()
issueto = inf2.get()
issueBtn.destroy()
labelFrame.destroy()
lb1.destroy()
inf1.destroy()
inf2.destroy()
if bid in allBid:
checkAvail = "select status from "+bookTable+" where bid
= '"+bid+"'"
cur.execute(checkAvail)
con.commit()
20
for i in cur:
check = i[0]
if check == 'avail':
status = True
else:
status = False
else:
messagebox.showinfo("Error","Book ID not present")
except:
messagebox.showinfo("Error","Can't fetch Book IDs")
print(bid)
print(issueto)
allBid.clear()
def issueBook():
global
issueBtn,labelFrame,lb1,inf1,inf2,quitBtn,root,Canvas1,status
Canvas1 = Canvas(root)
Canvas1.config(bg="#D6ED17")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#FFBB00",bd=5)
22
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0
.13)
labelFrame = Frame(root,bg='black')
labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.5)
# Book ID
lb1 = Label(labelFrame,text="Book ID : ", bg='black',
fg='white')
lb1.place(relx=0.05,rely=0.2)
inf1 = Entry(labelFrame)
inf1.place(relx=0.3,rely=0.2, relwidth=0.62)
inf2 = Entry(labelFrame)
inf2.place(relx=0.3,rely=0.4, relwidth=0.62)
#Issue Button
23
issueBtn = Button(root,text="Issue",bg='#d1ccc0',
fg='black',command=issue)
issueBtn.place(relx=0.28,rely=0.9,
relwidth=0.18,relheight=0.08)
root.mainloop()
24
#------------------------------Return Book-------------------------------
con =
pymysql.connect(host="localhost",user="root",password="tiger",
database="Csproject")
cur = con.cursor()
issueTable = "books_issued"
bookTable = "books"
allBid = []
def returnn():
global
SubmitBtn,labelFrame,lb1,bookInfo1,quitBtn,root,Canvas1,status
bid = bookInfo1.get()
if bid in allBid:
checkAvail = "select status from "+bookTable+" where bid
= '"+bid+"'"
cur.execute(checkAvail)
con.commit()
for i in cur:
check = i[0]
if check == 'issued':
status = True
else:
status = False
else:
messagebox.showinfo("Error","Book ID not present")
except:
messagebox.showinfo("Error","Can't fetch Book IDs")
print(bid in allBid)
print(status)
updateStatus = "update "+bookTable+" set status = 'avail'
where bid = '"+bid+"'"
26
try:
if bid in allBid and status == True:
cur.execute(issueSql)
con.commit()
cur.execute(updateStatus)
con.commit()
messagebox.showinfo('Success',"Book Returned
Successfully")
else:
allBid.clear()
messagebox.showinfo('Message',"Please check the book
ID")
root.destroy()
return
except:
messagebox.showinfo("Search Error","The value entered is
wrong, Try again")
allBid.clear()
root.destroy()
def returnBook():
global
bookInfo1,SubmitBtn,quitBtn,Canvas1,con,cur,root,labelFrame,
lb1
root = Tk()
27
root.title("Library")
root.minsize(width=400,height=400)
root.geometry("600x500")
Canvas1 = Canvas(root)
Canvas1.config(bg="#006B38")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0
.13)
labelFrame = Frame(root,bg='black')
labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.5)
# Book ID to Delete
lb1 = Label(labelFrame,text="Book ID : ", bg='black',
fg='white')
lb1.place(relx=0.05,rely=0.5)
bookInfo1 = Entry(labelFrame)
bookInfo1.place(relx=0.3,rely=0.5, relwidth=0.62)
28
#Submit Button
SubmitBtn = Button(root,text="Return",bg='#d1ccc0',
fg='black',command=returnn)
SubmitBtn.place(relx=0.28,rely=0.9,
relwidth=0.18,relheight=0.08)
OUTPU
T
• The books table
29
• The issued books table
30
• Add books window
31
• Delete book window
32
• Issue Books window
33
CONCLUSION
The following library management system is basically
aimed to help the user to manage the records of issuing,
returning adding the books.
The user has to just input details like book name,
Author and Book id of the book. All the data gets stored
in mysql database.
34
ANALYSI
S
This project has helped me to understand the basics of
python programming and to gain hands-on
experience on testing this knowledge of
python tkinter GUI(Graphical User Interface)module,
error handling, data validation, connectivity between
python frontend and mysql database backend.
35
BIBLIOGRAPHY :
• Stationary refered:
Computer Science With PYTHON By Sumita
Arora
• Websites:
i)https://python101.pythonlibrary.org/chapter21_thr ead.html
ii) https://pythonguides.com/python-tkintertodolist/
iii) https://www.geeksforgeeks.org/python-projects-
beginner-to-advanced/
36
37