Mohit Narula Cs Project FINAL
Mohit Narula Cs Project FINAL
1
SSVM WORLD SCHOOL
Department of Computer Science
Bonafide Certificate
2
ACKNOWLEDGEMENT
3
INDEX
S.No Contents Pg No
1. Introduction 1
3. About Tkinter 6
4. About MySQL 7
5. Software Implimentations 8
6. MySQL Table Structure 9
7. Source Code 12
8. Output 26
9. User Manual 43
10. Conclusion 46
11. Bibliography 47
4
INTRODUCTION
The purpose of a library management system is to
operate a library with efficiency and at reduced costs.
The system being entirely automated streamlines all the
tasks involved in operations of the library. The
activities of book purchasing, cataloging, indexing,
circulation recording and stock checking are done by
the software. Such software eliminates the need for
repetitive manual work and minimizes the chances of
errors.
The library management system software helps in
reducing operational costs. Managing a library
manually is labor intensive and an immense amount of
paperwork is involved. An automated system reduces
the need for manpower and stationery. This leads to
lower operational costs.The system saves time for both
the user and the librarian. With just a click the user
can search for the books available in the library. The
librarian can answer queries with ease regarding the
availability of books. Adding, removing or editing the
database is a simple process. Adding new members or
cancelling existing memberships can be done with ease.
5
OBJECTIVE AND SCOPE OF THE PROJECT
6
The main purpose of this project Is to reduce manual
work. This software is capable of managing book issues,
Returns etc. Here Librarian will be the administrator
to control members and manage books. He can issue
books and can see the dates of returning the book they
have issued.
7
ABOUT PYTHON IDLE
8
are:
• Multi-window text editor with syntax highlighting,
autocompletion, smart indent, and others.
• Python shell with syntax highlighting.
• Integrated debugger with stepping, persistent
breakpoints and callstack visits
9
Some of the characteristics of python that attract big
companies to use this programming language are:
• Interactive
• Interpreted
• Modular
• Dynamic
• Object-oriented
• Portable
• High level
• Extensible in C++ & C
10
Some of the advantages of python are:
• Extensive Support Libraries
• Integration feature
• Improved Programmer’s Productivity
11
ABOUT TKINTER
Key Features:
Widgets Galore: tkinter provides a wide range of
widgets (buttons, labels, etc.) for building interactive
GUIs.
12
Widget Variety: Offers a broad selection of widgets
to suit specific needs.
ABOUT MYSQL
13
dual landscape, consisting of MySQL and MariaDB,
provides users with versatile and robust database
management solutions.
Advantages of MYSQL:
14
SOFTWARE IMPLEMENTATION
SYSTEM TYPE:
SOFTWARE USED:
Microsoft Windows 11 as Operating System
Python IDLE 3.10 as front end
WPS Office for Documentation
MYSQL 3.11.2 for database
15
MYSQL TABLE
Books Table
Issue status
Return status
SOURCE CODE
16
from tkinter import *
from PIL import ImageTk,Image
#PIL -> Pillow
import pymysql
from tkinter import
messagebox
from AddBook import *
from DeleteBook import *
from ViewBooks import *
from IssueBook import *
mypass = "root" #use your own
password
mydatabase="db" #The
database name
con = pymysql.connect
(host="localhost",user="root",p
assword=mypass,database=my
database)
#root is the username here
newImageSizeWidth =
int(imageSizeWidth*n)
if same:
newImageSizeHeight =
int(imageSizeHeight*n)
else:
newImageSizeHeight =
int(imageSizeHeight/n)
background_image =
background_image.resize((new
ImageSizeWidth,newImageSize
Height),Image.ANTIALIAS)
img =
ImageTk.PhotoImage(backgrou
nd_image)
Canv1 = Canv(root)
Canv1.create_image(300,340,i
mage = img)
Canv1.config(bg="white",width
= newImageSizeWidth, height =
newImageSizeHeight)
18
Canv1.pack(expand=True,fill=B
OTH)
headingFrame1 =
Frame(root,bg="#FFBB00",bd=
5)
headingFrame1.place(relx=0.2,r
ely=0.1,relwidth=0.6,relheight=
0.16)
headingLabel =
Label(headingFrame1,
text="Welcome to \n DataFlair
Library", bg='black', fg='white',
font=('Courier',15))
headingLabel.place(relx=0,rely=
0, relwidth=1, relheight=1)
btn1 = Button(root,text="Add
Book Details",bg='black',
fg='white', command=addBook)
btn1.place(relx=0.28,rely=0.4,
relwidth=0.45,relheight=0.1)
btn2 =
Button(root,text="Delete
Book",bg='black', fg='white',
command=delete)
btn2.place(relx=0.28,rely=0.5,
relwidth=0.45,relheight=0.1)
btn3 = Button(root,text="View
Book List",bg='black',
19
fg='white', command=View)
btn3.place(relx=0.28,rely=0.6,
relwidth=0.45,relheight=0.1)
btn4 = Button(root,text="Issue
Book to Student",bg='black',
fg='white', command =
issueBook)
btn4.place(relx=0.28,rely=0.7,
relwidth=0.45,relheight=0.1)
btn5 =
Button(root,text="Return
Book",bg='black', fg='white',
command = returnBook)
btn5.place(relx=0.28,rely=0.8,
relwidth=0.45,relheight=0.1)
root.mainloop()
from tkinter import *
from PIL import ImageTk,Image
from tkinter import
messagebox
import pymysql
def bookRegister():
bid = bookInfo1.get()
title = bookInfo2.get()
author = bookInfo3.get()
status = bookInfo4.get()
status = status.lower()
20
insertBooks = "insert into
"+bookTable+" values
('"+bid+"','"+title+"','"+author+
"','"+status+"')"
try:
cur.execute(insertBooks)
con.commit()
messagebox.showinfo('Success'
,"Book added successfully")
except:
messagebox.showinfo("Error","
Can't add data into Database")
print(bid)
print(title)
print(author)
print(status)
root.destroy()
def addBook():
global bookInfo1 ,bookInfo2,
bookInfo3, bookInfo4, Canvas1,
con, cur, bookTable, root
root = Tk()
root.title("Library")
root.minsize(width=400,height
=400)
root.geometry("600x500")
21
mypass = "root"
mydatabase="db"
con =
pymysql.connect( host="localh
ost",user="root",password=my
pass,database=mydatabase)
cur = con.cursor()
Canv1 = Canv(root)
Canv1.config(bg="#ff6e40")
Canv1.pack(expand=True,fill=B
OTH)
headingFrame1 =
Frame(root,bg="#FFBB00",bd=
5)
headingFrame1.place(relx=0.25
,rely=0.1,relwidth=0.5,relheight
=0.13)
headingLabel =
22
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')
23
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)
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)
24
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=bookRegis
ter)
SubmitBtn.place(relx=0.28,rely
=0.9,
relwidth=0.18,relheight=0.08)
quitBtn =
Button(root,text="Quit",bg='#f
7f1e3', fg='black',
command=root.destroy)
quitBtn.place(relx=0.53,rely=0.
9,
relwidth=0.18,relheight=0.08)
def View():
root = Tk()
root.title("Library")
root.minsize(width=400,height
25
=400)
root.geometry("600x500")
Canv1 = Canv(root)
Canv1.config(bg="#12a4d9")
Canv1.pack(expand=True,fill=B
OTH)
headingFrame1 =
Frame(root,bg="#FFBB00",bd=
5)
headingFrame1.place(relx=0.25
,rely=0.1,relwidth=0.5,relheight
=0.13)
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)
26
y = 0.25
Label(labelFrame, text="%-
10s%-40s%-30s%-20s"%
('BID','Title','Author','Status'),
bg='black',fg='white').place(relx
=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
27
to fetch files from database")
quitBtn =
Button(root,text="Quit",bg='#f
7f1e3', fg='black',
command=root.destroy)
quitBtn.place(relx=0.4,rely=0.9,
relwidth=0.18,relheight=0.08)
def deleteBook():
bid = bookInfo1.get()
deleteSql = "delete from
"+bookTable+" where bid =
'"+bid+"'"
deleteIssue = "delete from
"+issueTable+" where bid =
'"+bid+"'"
try:
cur.execute(deleteSql)
con.commit()
cur.execute(deleteIssue)
con.commit()
messagebox.showinfo('Success'
,"Book Record Deleted
Successfully")
except:
28
messagebox.showinfo("Please
check Book ID")
print(bid)
bookInfo1.delete(0, END)
root.destroy()
def deleteBook():
bid = bookInfo1.get()
deleteSql = "delete from
"+bookTable+" where bid =
'"+bid+"'"
deleteIssue = "delete from
"+issueTable+" where bid =
'"+bid+"'"
try:
cur.execute(deleteSql)
con.commit()
cur.execute(deleteIssue)
con.commit()
messagebox.showinfo('Success'
,"Book Record Deleted
Successfully")
except:
29
messagebox.showinfo("Please
check Book ID")
print(bid)
bookInfo1.delete(0, END)
root.destroy()
def delete():
global
bookInfo1,bookInfo2,bookInfo3
,bookInfo4,Canvas1,con,cur,bo
okTable,root
root = Tk()
root.title("Library")
root.minsize(width=400,height
=400)
root.geometry("600x500")
Canv1 = Canv(root)
Canv1.config(bg="#006B38")
Canv1.pack(expand=True,fill=B
OTH)
headingFrame1 =
Frame(root,bg="#FFBB00",bd=
5)
headingFrame1.place(relx=0.25
30
,rely=0.1,relwidth=0.5,relheight
=0.13)
headingLabel =
Label(headingFrame1,
text="Delete Book", 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)
# 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',
31
fg='black',command=deleteBoo
k)
SubmitBtn.place(relx=0.28,rely
=0.9,
relwidth=0.18,relheight=0.08)
quitBtn =
Button(root,text="Quit",bg='#f
7f1e3', fg='black',
command=root.destroy)
quitBtn.place(relx=0.53,rely=0.
9,
relwidth=0.18,relheight=0.08)
def issue():
global
issueBtn,labelFrame,lb1,inf1,inf
2,quitBtn,root,Canvas1,status
bid = inf1.get()
issueto = inf2.get()
issueBtn.destroy()
labelFrame.destroy()
lb1.destroy()
inf1.destroy()
inf2.destroy()
32
try:
cur.execute(extractBid)
con.commit()
for i in cur:
allBid.append(i[0])
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 == 'avail':
status = True
else:
status = False
else:
messagebox.showinfo("Error","
Book ID not present")
except:
messagebox.showinfo("Error","
Can't fetch Book IDs")
issueSql = "insert into
"+issueTable+" values
('"+bid+"','"+issueto+"')"
33
show = "select * from
"+issueTable
updateStatus = "update
"+bookTable+" set status =
'issued' where bid = '"+bid+"'"
try:
if bid in allBid and status
== True:
cur.execute(issueSql)
con.commit()
cur.execute(updateStatus)
con.commit()
messagebox.showinfo('Success'
,"Book Issued Successfully")
root.destroy()
else:
allBid.clear()
messagebox.showinfo('Messag
e',"Book Already Issued")
root.destroy()
return
except:
messagebox.showinfo("Search
Error","The value entered is
wrong, Try again")
print(bid)
34
print(issueto)
allBid.clear()
def issueBook():
global
issueBtn,labelFrame,lb1,inf1,inf
2,quitBtn,root,Canvas1,status
root = Tk()
root.title("Library")
root.minsize(width=400,height
=400)
root.geometry("600x500")
Canv1 = Canv(root)
Canv1.config(bg="#D6ED17")
Canv1.pack(expand=True,fill=B
OTH)
headingFrame1 =
Frame(root,bg="#FFBB00",bd=
5)
headingFrame1.place(relx=0.25
,rely=0.1,relwidth=0.5,relheight
=0.13)
headingLabel =
Label(headingFrame1,
text="Issue Book", bg='black',
35
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)
# 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)
# Issued To Student name
lb2 =
Label(labelFrame,text="Issued
To : ", bg='black', fg='white')
lb2.place(relx=0.05,rely=0.4)
inf2 = Entry(labelFrame)
inf2.place(relx=0.3,rely=0.4,
relwidth=0.62)
#Issue Button
issueBtn =
36
Button(root,text="Issue",bg='#
d1ccc0',
fg='black',command=issue)
issueBtn.place(relx=0.28,rely=0
.9,
relwidth=0.18,relheight=0.08)
quitBtn =
Button(root,text="Quit",bg='#a
aa69d', fg='black',
command=root.destroy)
quitBtn.place(relx=0.53,rely=0.
9,
relwidth=0.18,relheight=0.08)
def returnn():
global
SubmitBtn,labelFrame,lb1,book
Info1,quitBtn,root,Canvas1,stat
us
bid = bookInfo1.get()
37
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")
38
'avail' where bid = '"+bid+"'"
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('Messag
e',"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,C
anvas1,con,cur,root,labelFrame
39
, lb1
root = Tk()
root.title("Library")
root.minsize(width=400,height
=400)
root.geometry("600x500")
Canv1 = Canv(root)
Canv1.config(bg="#006B38")
Canv1.pack(expand=True,fill=B
OTH)
headingFrame1 =
Frame(root,bg="#FFBB00",bd=
5)
headingFrame1.place(relx=0.25
,rely=0.1,relwidth=0.5,relheight
=0.13)
headingLabel =
Label(headingFrame1,
text="Return Book", bg='black',
fg='white', font=('Courier',15))
headingLabel.place(relx=0,rely=
0, relwidth=1, relheight=1)
labelFrame =
40
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)
#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)
quitBtn =
Button(root,text="Quit",bg='#f
7f1e3', fg='black',
command=root.destroy)
quitBtn.place(relx=0.53,rely=0.
41
9,
relwidth=0.18,relheight=0.08)
root.mainloop()
42
43
OUTPUT
On Startup
44
45
46
47
48
49
50
51
52
53
54
55
56
USER MANUAL
Manually updating the library system into
an android-based application so that the
user can know the details of the books
available and maximum limit on
borrowing from their computer and
through their phones.
The library management System provides
information's like details of the books,
insertion of new books, deletion of lost
books, limitation on issuing books, fine on
keeping a book more than one month
from the issued date.
Also user can provide feedback for adding
some new books to the library
OVERALL DESCRIPTION
2.1 PRODUCT PRESPECTIVE
The proposed Library Management
System will take care of the current book
detail at any point of time. The book issue,
book return will update the current book
57
details automatically so that user will get
the update current book details.
System Requirements:
To execute the project successfully, ensure the following
prerequisites:
Operating System: Windows 7/8/10
Programming Language: Python 3.7 and above
Database Management System: MySQL 3.8 and above
58
CONCLUSION
The library management system software helps
in reducing operational costs. Managing a library
manually is labor intensive and an immense
amount of paperwork is involved. An automated
system reduces the need for manpower and
stationery. This leads to lower operational
costs.The Library Management System is much
more user-friendly, faster in operation and easy
to manage than the manual one.The goals that are
achieved by the software are :
User friendly.
59
BIBLIOGRAPHY
1. Computer Science with Python, Class XI Textbook by
SumitaArora, 2021 Edition, Published by Dhanpat Rai & Co. 2022
2. Computer Science with Python, Class XII Textbook by Sumita
Arora, 2021 Edition, Published by Dhanpat Rai & Co. 2022
3.Python.10.9Documentation
https://docs.python.org/3.10/library/tkinter.html
https://docs.python.org/3.10/library/datetime.html
5. GeeksForGeeks https://www.geeksforgeeks.org/python-tkinter-
scrolledtextwidget/
60