0% found this document useful (0 votes)
33 views37 pages

Comp Sci Anuu

This document summarizes a library management system project created by three students - Dhawani Shetty, Kumari Anamika, and Sohit Yadav. The project uses Python and MySQL to allow a library manager to add, view, issue, and return books. The program code uses a GUI created with Tkinter to display buttons and entries for different functions like adding book details, deleting books, and viewing book lists stored in the MySQL database table. Output is displayed and changes are simultaneously updated in the database when books are edited or deleted.

Uploaded by

kunal.1214155669
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views37 pages

Comp Sci Anuu

This document summarizes a library management system project created by three students - Dhawani Shetty, Kumari Anamika, and Sohit Yadav. The project uses Python and MySQL to allow a library manager to add, view, issue, and return books. The program code uses a GUI created with Tkinter to display buttons and entries for different functions like adding book details, deleting books, and viewing book lists stored in the MySQL database table. Output is displayed and changes are simultaneously updated in the database when books are edited or deleted.

Uploaded by

kunal.1214155669
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 37

COMPUTER SCIENCE PROJECT

(SESSION:2023-24)

LIBRARY MANAGEMENT SYSTEM


CLASS: XII-A
GROUP MEMBERS: DHWANI SHETTY , KUMARI ANAMIKA ,
SOHIT YADAV
SUBMITTED TO: MR.DILLIP INGLE

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).

Name: Kumari Anamika

Board Roll No. -

Signature of Principal :

Signature of Internal Examiner:

Signature of External Examiner:

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

➢Processor : Intel® Core™ i3-3110


➢Ram : 64 MB
➢Hard disk: 4 GB.

❖ 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()

root = Tk() root.title("Library")


root.minsize(width=400,height=400)
root.geometry("600x500")

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)

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)
8
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', 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()

9
#-------------------------------Add books--------------------------------

def bookRegister():

bid = bookInfo1.get()
title = bookInfo2.get()
author = bookInfo3.get()
status = bookInfo4.get()
status = status.lower()

insertBooks = "insert into "+”books”+"


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():
10
global
bookInfo1,bookInfo2,bookInfo3,bookInfo4,Canvas1,con,cur,book
Table,root

root = Tk() root.title("Library")


root.minsize(width=400,height=400)
root.geometry("600x500")

con =
pymysql.connect(host="localhost",user="root",password="tiger",
database="Csproject")
cur = con.cursor()

# Enter Table Names here


bookTable = "books" # Book Table

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)

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()

13
#-------------------------------View Books-------------------------------

con =
pymysql.connect(host="localhost",user="root",password="tiger",
database="Csproject")
cur = con.cursor()

bookTable = "books"

def View():

root = Tk() root.title("Library")


root.minsize(width=400,height=400)
root.geometry("600x500")

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")

quitBtn = Button(root,text="Quit",bg='#f7f1e3', fg='black',


command=root.destroy)
quitBtn.place(relx=0.4,rely=0.9, relwidth=0.18,relheight=0.08)
15
root.mainloop()

#------------------------------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()

deleteSql = "delete from "+bookTable+" where bid = '"+bid+"'"


deleteIssue = "delete from "+issueTable+" where bid =
'"+bid+"'"
try:
cur.execute(deleteSql)
16
con.commit()
cur.execute(deleteIssue)
con.commit()
messagebox.showinfo('Success',"Book Record Deleted
Successfully")
except:
messagebox.showinfo("Please check Book ID")

print(bid)

bookInfo1.delete(0, END)
root.destroy()

def delete():

global
bookInfo1,bookInfo2,bookInfo3,bookInfo4,Canvas1,con,cur,book
Table,root

root = Tk() root.title("Library")


root.minsize(width=400,height=400)
root.geometry("600x500")

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)

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',
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()

extractBid = "select bid from "+bookTable


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()
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")

issueSql = "insert into "+issueTable+" values


('"+bid+"','"+issueto+"')"
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:
21
allBid.clear()
messagebox.showinfo('Message',"Book Already Issued")
root.destroy()
return
except:
messagebox.showinfo("Search Error","The value entered is
wrong, Try again")

print(bid)
print(issueto)

allBid.clear()

def issueBook():

global
issueBtn,labelFrame,lb1,inf1,inf2,quitBtn,root,Canvas1,status

root = Tk() root.title("Library")


root.minsize(width=400,height=400)
root.geometry("600x500")

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)

headingLabel = Label(headingFrame1, text="Issue 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
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
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)

quitBtn = Button(root,text="Quit",bg='#aaa69d', fg='black',


command=root.destroy)
quitBtn.place(relx=0.53,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()

extractBid = "select bid from "+issueTable


try:
cur.execute(extractBid)
25
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 == 'issued':
status = True
else:
status = False

else:
messagebox.showinfo("Error","Book ID not present")
except:
messagebox.showinfo("Error","Can't fetch Book IDs")

issueSql = "delete from "+issueTable+" where bid = '"+bid+"'"

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)

headingLabel = Label(headingFrame1, text="Return 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
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)

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()

OUTPU
T
• The books table

29
• The issued books table

• The Main Menu

30
• Add books window

• View Books window

31
• Delete book window

• Return Books 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

You might also like