Class 12 CS Project - Library Management System

You are on page 1of 53

Library Management System

Group Project By: -


1) Siddharth Sinha
2) Ali Ahmad


Computer Science Grade XII

Teacher – Mr. Prashant Kumar
Certificate

This is to certify that Siddharth Sinha of


Grade – XII ‘A’, The Tribhuvan School, Patna has completed the
project titled ‘Library Management System’ during the academic year
2022-23 towards partial fulfillment of the computer science practical
examination conducted by CBSE, New Delhi & submitted satisfactory
report as compiled in the following pages, under my supervision.

Mr. Prashant Kumar Mrs. Mahua Das Gupta


PGT, Computer Science Principal

_________________ _________________
External

_________________
Acknowledgement

I would like to express my special thanks of gratitude to


my teacher Mr. Prashant Kumar who gave me the
excellent opportunity to do this wonderful project on
the topic ‘Library Management System’, which also
helped me in doing a lot of Research and I came to
know about so many new things.

Secondly, I would also like to thank my parents and


friends who helped me a lot in finalizing this project
within the limited time frame.
Index
1) Problem Statement

2) Current Setup

3) What will the project help with?

a. Objective and Scope

4) Functionalities Provided

5) Technical Modules Provided

6) Reports Of LMS

7) Software Requirements

8) Hardware Requirements

9) Input Data and Validation of Project on LMS

10) Future Scope

11) SOURCE CODE

12) Conclusion

13) Bibliography
Problem statement
Introduction: What is the project about?

The “Library Management System” has been developed to override


the problems prevailing in the practicing manual system. This
software is supported to eliminate and, in some cases, reduce the
hardships faced by this existing system. Moreover, this system is
designed for the particular need of the company to carry out
operations in a smooth and effective manner.

The application is reduced as much as possible to avoid errors while


entering the data It also provides error message while entering
invalid data. No formal knowledge is needed for the user to use this
system. Thus, by this all, it proves as user-friendly. Library
management System, as described above, can lead to error-free,
secure, reliable and fast management system. It can assist user to
concentrate on their other activities rather than concentrating on
record keeping. Thus, it will help in organizing a better utilization of
resources.
Current Setup

The current setup of the library is mostly based on hand-written


system. For example – The indexing of books is done with hand by
writing in the notebooks, the student issues are noted in notebooks,
etc. This system has many flaws, for example – the notebooks can
easily be misplaced, lost or tampered with i.e. data once lost is
completely lost and the process has to be started again.
Also the backtracking and overall management of data is quite
difficult, for example – a librarian can get many requests at once and
handling all of them while writing every record in the notebook can
be very time taking and tedious. The librarian also has to keep track
of all the issues, returns and fines for the books that were returned
after the due date.
This project provides a simple solution to all these problems by
removing the need to type everything in notebooks and replacing it
with a highly efficient and easily manageable database to keep track
of everything.
What will the project help with?

The main objective of the project on Library Management System is


to manage the details of students, books, issues, members, etc. The
project is totally built at administrative end and thus only the
administrator is granted the access. The purpose of this project is to
reduce the manual work for managing the Students, Books, Address,
Issues, etcetera.

Objective and Scope of the Project

 In computer system the person has to fill the various forms and
numbers of copies of the forms can be easily generated at a
time.
 It is not necessary to create the manifest but we can directly
print it, which saves time.
 To assist the staff in capturing the effort spent on their
respective working areas.
 To utilize the resources in an efficient manner by increasing
their productivity through automation.
 The system generates types of information that can be used for
various purposes.
 It satisfies the user requirement.
 Easy to understand by the user and operator.
 Easy to expand.
 Has a good user interface.
 Delivered on schedule within the budget.
Functionalities provided by Library Management
Systems:

 Managing book inventory


 Provides the searching facilities based on various
factors such as Student, Issue, etc.
 Library Management System also manages the
address detail online.
 It tracks all the information of Books & Student.
 To increase efficiency of managing data.
 Editing, adding and updating of records is
improved which results in proper resource
management of student data.
 Integration of all records of members.
Technical Modules provided by Library
Management Systems:

1) Cataloging of Books
a) Add Book Details -- Add a new book to library
b) Delete Book -- Remove a book from the library
2) Viewing the Data
a) View Book List -- Shows a list of all the books in
the library
b) View Issue List -- Shows a list of books issued to
students/members
3) Management of Issues
a) Issue Book -- Issue a book from the library to a
student/member
b) Return Book -- Return an issued book back to
the library.
Reports of Library Management System:

 It generates the report on Student, Books, issues,


etc.
 Provide filter reports on Issues, Librarian,
Members.
 You can easily export PDF for the student, address,
librarian.
 Application also provides excel export for books,
Issues, member.
Software Requirement

Name of component Specification

Operating System Windows 7 and above, Linux,


Ubuntu.

IDE IDLE Python

Database MySQL Server

Front End Python 3.6 or above

Hardware Requirements

Name of component Specification


Processor Intel Core i3 4th Gen and above or
AMD equivalent.
RAM 4GB (minimum), 8GB(preferred).

Storage At least 15GB free space.

Display At least 800x600 resolution display.


Input Data and Validation of Project on Library
Management Systems

 All the fields such as student, Issues, member are validated and
does not take invalid values.
 Avoiding errors in data.
 Controlling amount of input.
 Integration of all modules/forms in the system.
 Preparation of the test cases.
 Preparation of the possible test data with all the validation
checks.
 Actual testing done manually.

Input/
Output
MySQL sends output via Python User sends data to Python
after executing the commands

MySQL Python
Command Command
Executer Interpreter

Python Interprets the data and


sends suitable commands to
MySQL
Future Scope of the project:

In a nutshell, it can be summarized that the future scope of the


project circles around maintaining information regarding:
 We can add printer in the future.
 We can give more advanced software for Library Management
System including more facilities.
 We will host the platform on online servers to make it
accessible worldwide.
 Integrate multiple load balances to distribute load of the
system.
 Create the master and slave database structures to reduce the
overload of database queries.
 Implement the backup mechanism for taking backup of
codebase and database on regular basis on different servers.

The above-mentioned points are the enhancements which can be


done to increase the applicability and usage of this project. Here, we
can maintain the records of student and books. Also, as it can be
seen that nowadays, the players are versatile i.e., there is scope for
introducing a method to maintain the Library Management System.
Enhancements can be done to maintain all the students, books,
issues, librarian, members.
We have left all the options open so that if there is any future
requirement in the system by the user for the enhancement of the
system then it is possible to implement them. At last, we would like
to thank all the people involved in the development of the system
directly or indirectly. We hope that the project will serve its purpose
for which it is developed.
Source
Code
Base File - Main.py

from tkinter import *


from tkinter import messagebox, ttk
import mysql.connector as msql
try:
from NewUser import *
from AddBook import *
from DeleteBook import *
from IssueBook import *
from issueList import *
from ReturnBook import returnBook, returnn
from ViewBooks import *
except:
print('-----------------------------------Rerun program even if you see a window----------------------
-------------!!')
def user():
def kill():
root.destroy()
def help():
hp = Tk()
hp.title("Help")
hp.minsize(width=400,height=400)
hp.geometry("800x600")
Canvas1 = Canvas(hp)
Canvas1.config(bg="#12a4d9",width = 800, height = 600)
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(hp,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.2,rely=0.1,relwidth=0.6,relheight=0.16)
headingLabel = Label(headingFrame1, text="Help Page", bg='black', fg='white',
font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)
hl=Label(hp, text="Add Book Details -- Add a new book to library\n\nDelete Book --
Remove a book from the library\n\nView Book List -- Shows a list of all the books in the
library\n\nView Issue List -- Shows a list of books issued to students/members\n\nIssue
Book -- Issue a book from the library to a student/member\n\nReturn Book -- Return an
issued book back to the library.",font=('Verdana',14))
hl.config(bg="#12a4d9")
hl.place(relx=0,rely=0.3, relwidth=1, relheight=0.6)
root = Tk()
root.title("Library")
root.minsize(width=400,height=400)
root.geometry("1200x600")
Canvas1 = Canvas(root)
Canvas1.config(bg="#12a4d9",width = 1200, height = 600)
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.2,rely=0.05,relwidth=0.6,relheight=0.16)
headingLabel = Label(headingFrame1, text="Welcome to\nTTS Library", bg='black',
fg='white', font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)
btn3 = Button(root,text="View Book List",bg='black', fg='white', command=View)
btn3.place(relx=0.28,rely=0.25, relwidth=0.45,relheight=0.1)
btn4 = Button(root,text="View Issue List",bg='black', fg='white', command=issuelist)
btn4.place(relx=0.28,rely=0.35, relwidth=0.45,relheight=0.1)
btn5 = Button(root,text="Issue Book",bg='black', fg='white', command = issueBook)
btn5.place(relx=0.28,rely=0.45, relwidth=0.45,relheight=0.1)
btn6 = Button(root,text="Return Book",bg='black', fg='white', command = returnBook)
btn6.place(relx=0.28,rely=0.55, relwidth=0.45,relheight=0.1)
btn7 = Button(root,text="Quit",bg='black', fg='white', command = kill)
btn7.place(relx=0.28,rely=0.65, relwidth=0.45,relheight=0.1)
btn8 = Button(root,text="?",bg='black', fg='white', command = help)
btn8.place(relx=0.8,rely=0.5, relwidth=0.05,relheight=0.05)
root.mainloop()
def main():
def kill():
root.destroy()
def help():
hp = Tk()
hp.title("Help")
hp.minsize(width=400,height=400)
hp.geometry("800x600")
Canvas1 = Canvas(hp)
Canvas1.config(bg="#12a4d9",width = 800, height = 600)
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(hp,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.2,rely=0.1,relwidth=0.6,relheight=0.16)
headingLabel = Label(headingFrame1, text="Help Page", bg='black', fg='white',
font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)
hl=Label(hp, text="Add Book Details -- Add a new book to library\n\nDelete Book --
Remove a book from the library\n\nView Book List -- Shows a list of all the books in the
library\n\nView Issue List -- Shows a list of books issued to students/members\n\nIssue
Book -- Issue a book from the library to a student/member\n\nReturn Book -- Return an
issued book back to the library.",font=('Verdana',14))
hl.config(bg="#12a4d9")
hl.place(relx=0,rely=0.3, relwidth=1, relheight=0.6)
root = Tk()
root.title("Library")
root.minsize(width=400,height=400)
root.geometry("1200x600")
Canvas1 = Canvas(root)
Canvas1.config(bg="#12a4d9",width = 1200, height = 600)
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.2,rely=0.05,relwidth=0.6,relheight=0.16)
headingLabel = Label(headingFrame1, text="Welcome to\nTTS 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.25, 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.35, 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.45, relwidth=0.45,relheight=0.1)
btn4 = Button(root,text="View Issue List",bg='black', fg='white', command=issuelist)
btn4.place(relx=0.28,rely=0.55, relwidth=0.45,relheight=0.1)
btn5 = Button(root,text="Issue Book",bg='black', fg='white', command = issueBook)
btn5.place(relx=0.28,rely=0.65, relwidth=0.45,relheight=0.1)
btn6 = Button(root,text="Return Book",bg='black', fg='white', command = returnBook)
btn6.place(relx=0.28,rely=0.75, relwidth=0.45,relheight=0.1)
btn7 = Button(root,text="Quit",bg='black', fg='white', command = kill)
btn7.place(relx=0.28,rely=0.85, relwidth=0.45,relheight=0.1)
btn8 = Button(root,text="?",bg='black', fg='white', command = help)
btn8.place(relx=0.8,rely=0.5, relwidth=0.05,relheight=0.05)
btn9 = Button(root,text="Create new USER",bg='black', fg='white', command = newUser)
btn9.place(relx=0.1,rely=0.5, relwidth=0.15,relheight=0.05)
root.mainloop()

def clear():
uname.delete(0, END)
entry.delete(0, END)
try:
mycon=msql.connect(host='localhost', user='root', passwd='root', database='lib')
if mycon.is_connected():
print('Successfully connected!')
if mycon.is_connected()==False:
print('Error!')
mycon.close()
except:
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="root"
)
mycursor = mydb.cursor()
mycursor.execute("CREATE DATABASE lib")
mydb.close()
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="root",
database='lib'
)
mycursor = mydb.cursor()
mycursor.execute("create table books(bid varchar(20) primary key, title varchar(30),
author varchar(30), status varchar(30));")
mycursor.execute("create table books_issued(bid varchar(20) primary key, issuedto
varchar(30), issuedate varchar(20));")
print('Database does not exist!\n---------CREATING DATABASE---------\n---------DATABASE
CREATED---------\n---------Rerun the Program---------')
try:
mycon=msql.connect(host='localhost', user='root', passwd='root', database='login')
if mycon.is_connected():
print('Successfully connected!')
if mycon.is_connected()==False:
print('Error!')
cur=mycon.cursor()
try:
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="root",
database='login'
)
mycursor = mydb.cursor()
mycursor.execute("select * from uname;")
f=mycursor.fetchall()
e=('master','root','y')
if e not in f:
mycursor.execute("insert into uname values('master','root','y');")
mydb.commit()
else:
print('continue')
except:
print('continue2')

def next1(event):
entry.focus_set()
def next2(event):
enter.focus_set()
win = Tk()
win.geometry("400x200")
password = StringVar()
username = StringVar()
try:
cur.execute("select * from uname")
f=cur.fetchall()
def log():
p = password.get()
u = username.get()
z = ['y','n']
for i in z:
x = (u,p,i)
if x in f:
win.destroy()
if i=='y':
main()
else:
user()
break
else:
ttk.Label(win, text="Wrong Username or Password").pack()
def log2(event):
p = password.get()
u = username.get()
z = ['y','n']
for i in z:
x = (u,p,i)
if x in f:
win.destroy()
if i=='y':
main()
else:
user()
break
else:
ttk.Label(win, text="Wrong Username or Password").pack()
ttk.Label(win, text="Username").pack()
uname = Entry(win, width=25, textvariable=username)
uname.pack(pady=10)
uname.bind('<Return>', next1)
ttk.Label(win, text="Password").pack()
entry = Entry(win, width=25, textvariable=password, show="*")
entry.pack(pady=10)
entry.bind('<Return>', next2)
enter = Button(win, text="Login", command=log)
enter.bind('<Return>', log2)
enter.pack()
ttk.Label(win, text="(Keep hitting Enter to navigate / submit or\n or press button
to submit!)").pack()

win.mainloop()
except:
print('Cannot fetch data from db')
mycon.close()
except:
import mysql.connector
try:
mycon=msql.connect(host='localhost', user='root', passwd='root', database='login')
mycon.close()
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="root",
database='login'
)
mycursor = mydb.cursor()
mycursor.execute("create table uname(uname varchar(30) primary key, pass
varchar(30), trueadmin varchar(1));")
mycursor.execute("select * from uname;")
f=mycursor.fetchall()
e=('master','root','y')
if e in f:
print('continue')
else:
mycursor.execute("insert into uname values('master','root','y');")
print('Database does not exist!\n---------CREATING DATABASE---------\n---------
DATABASE CREATED---------\n---------Rerun the Program---------')
except:
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="root"
)
mycursor = mydb.cursor()
mycursor.execute("CREATE DATABASE login")
mydb.close()
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="root",
database='login'
)
mycursor = mydb.cursor()
mycursor.execute("create table uname(uname varchar(30) primary key, pass varchar(30),
trueadmin varchar(1));")
mycursor.execute("select * from uname;")
f=mycursor.fetchall()
e=('master','root','y')
if e in f:
print('continue')
else:
mycursor.execute("insert into uname values('master','root','y');")
print('Database does not exist!\n---------CREATING DATABASE---------\n---------DATABASE
CREATED---------\n---------Rerun the Program---------')
Functions Used:-
AddBook.py

from tkinter import *


import mysql.connector as msql
from tkinter import messagebox
mycon=msql.connect(host='localhost', user='root', passwd='root', database='lib')
cur=mycon.cursor()
def addBook():
global bookInfo1 ,bookInfo2, bookInfo3, bookInfo4, Canvas1, mycon, cur, bookTable, root
root = Tk()
root.title("Library")
root.minsize(width=400,height=400)
root.geometry("600x500")
mycon=msql.connect(host='localhost', user='root', passwd='root', database='lib')
cur = mycon.cursor()
# Enter Table Names here
bookTable = "books" # Book Table
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)
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)
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()
def bookRegister():
bid = bookInfo1.get()
title = bookInfo2.get()
author = bookInfo3.get()
status = bookInfo4.get()
status = status.lower()
insertBooks = "insert into "+bookTable+" values
('"+bid+"','"+title+"','"+author+"','"+status+"')"
try:
cur.execute(insertBooks)
mycon.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()
DeleteBook.py

from tkinter import *


import mysql.connector as msql
from tkinter import messagebox
mycon=msql.connect(host='localhost', user='root', passwd='root', database='lib')
cur=mycon.cursor()
def deleteBook():
global bookInfo1 ,bookInfo2, bookInfo3, bookInfo4, Canvas1, mycon, cur, bookTable, root
bookTable = "books"
issueTable = "books_issued"
bid = bookInfo1.get()
deleteSql = "delete from "+bookTable+" where bid = '"+bid+"'"
deleteIssue = "delete from "+issueTable+" where bid = '"+bid+"'"
try:
print(bid)
cur.execute(deleteSql)
mycon.commit()
cur.execute(deleteIssue)
mycon.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,mycon,cur,bookTable,root
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)
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)
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.py
from tkinter import *
import mysql.connector as msql
from tkinter import messagebox
mycon=msql.connect(host='localhost', user='root', passwd='root', database='lib')
cur=mycon.cursor()
def issue():
global bookInfo1 ,bookInfo2, bookInfo3, bookInfo4, Canvas1, mycon, cur, bookTable, root
global issueBtn,labelFrame,lb1,inf1,inf2,inf3,quitBtn,root,Canvas1,status
bookTable = "books"
issueTable = "books_issued"
allBid = []
bid = inf1.get()
issueto = inf2.get()
issuedate = inf3.get()
issueBtn.destroy()
labelFrame.destroy()
lb1.destroy()
inf1.destroy()
inf2.destroy()
inf3.destroy()
extractBid = "select bid from "+bookTable
try:
cur.execute(extractBid)
for i in cur:
allBid.append(i[0])
mycon.commit()
if bid in allBid:
checkAvail = "select status from "+bookTable+" where bid = '"+bid+"'"
cur.execute(checkAvail)
for i in cur:
check = i[0]
if check == 'avail':
status = True
else:
status = False
mycon.commit()
else:
messagebox.showinfo("Error","Book ID not present")
except:
messagebox.showinfo("Error","Can't fetch Book IDs")
issueSql = "insert into "+issueTable+" values ('"+bid+"','"+issueto+"','"+issuedate+"')"
show = "select * from "+issueTable
updateStatus = "update "+bookTable+" set status = 'issued' where bid = '"+bid+"'"
try:
if bid in allBid and status == True:
cur.execute(issueSql)
mycon.commit()
cur.execute(updateStatus)
mycon.commit()
messagebox.showinfo('Success',"Book Issued Successfully")
root.destroy()
else:
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,inf3,quitBtn,root,Canvas1,status
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)
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)
lb3 = Label(labelFrame,text="Issued Date : ", bg='black', fg='white')
lb3.place(relx=0.05,rely=0.6)
inf3 = Entry(labelFrame)
inf3.place(relx=0.3,rely=0.6, relwidth=0.62)
#Issue Button
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()
IssueList.py
from tkinter import *
import mysql.connector as msql
from tkinter import messagebox
mycon=msql.connect(host='localhost', user='root', passwd='root', database='lib')
cur=mycon.cursor()
def issuelist():
global bookInfo1 ,bookInfo2, bookInfo3, bookInfo4, Canvas1, mycon, cur, bookTable, root
bookTable = "books_issued"
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)
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%-20s"%('BID','Issued To','Issue Date'),
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)
for i in cur:
Label(labelFrame,text="%-10s%-40s%-20s"%(i[0],i[1],i[2]) ,bg='black',
fg='white').place(relx=0.07,rely=y)
y += 0.1
mycon.commit()
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)
root.mainloop()
NewUser.py
from tkinter import *
from tkinter import messagebox, ttk
import mysql.connector as msql
mycon=msql.connect(host='localhost', username='root', passwd='root', database='login')
cur=mycon.cursor()
def newUser():
global password, username, tadmin, mycon, cur, root
def next1(event):
ent.focus_set()
def next2(event):
ent3.focus_set()
def next3(event):
enter.focus_set()
new = Tk()
new.geometry("600x400")
password = StringVar()
username = StringVar()
tadmin = StringVar()
ttk.Label(new, text="Username").pack()
name = Entry(new, width=25, textvariable=username)
name.pack(pady=10)
name.bind('<Return>', next1)
ttk.Label(new, text="Password").pack()
ent = Entry(new, width=25, textvariable=password)
ent.pack(pady=10)
ent.bind('<Return>', next2)
ttk.Label(new, text="Admin Permission (y/n)").pack()
ent3 = Entry(new, width=25, textvariable=tadmin)
ent3.pack(pady=10)
ent3.bind('<Return>', next3)
def y():
p=ent.get()
u = name.get()
b = ent3.get()
print(u,p,b)
sqls="insert into uname values ('"+u+"','"+p+"','"+b+"');"
print(sqls)
cur.execute(sqls)
mycon.commit()
messagebox.showinfo('Success',"User added successfully")
new.destroy()
def y2(event):
p=ent.get()
u = name.get()
b = ent3.get()
print(u,p,b)
sqls="insert into uname values ('"+u+"','"+p+"','"+b+"');"
print(sqls)
cur.execute(sqls)
mycon.commit()
messagebox.showinfo('Success',"User added successfully")
new.destroy()
enter = Button(new, text="Add User", command=y)
enter.bind('<Return>', y2)
enter.pack()
mycon.commit()
ttk.Label(new, text="(Keep hitting Enter to navigate / submit or\n or press button to
submit!)").pack()
new.mainloop()
mycon.close()
ReturnBook.py
from tkinter import *
import mysql.connector as msql
from tkinter import messagebox
mycon=msql.connect(host='localhost', user='root', passwd='root', database='lib')
cur=mycon.cursor()
issueTable = "books_issued"
bookTable = "books"
allBid = [] #To store all the Book ID’s
def returnn():
global bookInfo1 ,bookInfo2, bookInfo3, bookInfo4, Canvas1, mycon, cur, bookTable, root
global SubmitBtn,labelFrame,lb1,bookInfo1,quitBtn,root,Canvas1,status
bookTable = "books"
bid = bookInfo1.get()
extractBid = "select bid from "+issueTable
try:
cur.execute(extractBid)
for i in cur:
allBid.append(i[0])
mycon.commit()
if bid in allBid:
checkAvail = "select status from "+bookTable+" where bid = '"+bid+"'"
cur.execute(checkAvail)
for i in cur:
check = i[0]
if check == 'issued':
status = True
else:
status = False
mycon.commit()
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+"'"
try:
if bid in allBid and status == True:
cur.execute(issueSql)
mycon.commit()
cur.execute(updateStatus)
mycon.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,mycon,cur,root,labelFrame, lb1
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)
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)
#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()
ViewBooks.py
from tkinter import *
import mysql.connector as msql
from tkinter import messagebox
mycon=msql.connect(host='localhost', user='root', passwd='root', database='lib')
cur=mycon.cursor()
def View():
global bookInfo1 ,bookInfo2, bookInfo3, bookInfo4, Canvas1, mycon, cur, bookTable, root
bookTable = "books"
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)
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(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)
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
mycon.commit()
except:
messagebox.showinfo("Error","Failed to fetch files from database")
def export():
ex='select * from books'
cur.execute(ex)
l=cur.fetchall()
fh=open(".//Exports//data.txt","w")
for i in l:
i=str(i)+'\n'
fh.write(str(i))
messagebox.showinfo("Success","File exported to CS_Project/Exports/data.txt")
quitBtn = Button(root,text="Quit",bg='#f7f1e3', fg='black', command=root.destroy)
quitBtn.place(relx=0.6,rely=0.9, relwidth=0.18,relheight=0.08)
exBtn = Button(root,text="Export",bg='#f7f1e3', fg='black', command=export)
exBtn.place(relx=0.2,rely=0.9, relwidth=0.18,relheight=0.08)
root.mainloop()
Output
Login:

Master Main Screen:


User Main Screen:

Add Books:
Delete Book:

View Books:
Issue List:

Issue Books:
Return Book:

Create New User:


Help:
Conclusion of the Project Library
Management Systems:

Our project is only a humble venture to satisfy the needs to manage


a Library System. Several user-friendly coding has been adopted. This
package shall prove to be a powerful package in satisfying all the
requirements of the school. The objective of software planning is to
provide a frame work that enables the manager to make reasonable
estimates made within a limited time frame at the beginning of the
software project and should be updated regularly as the project
progresses. At the end, it is concluded that we have made effort on
following points…
 A description of the background and context of the project and
its relation to work already done in the area.
 Made statement of the aims and objectives of the project.
 The description of purpose, scope and applicability.
 We define the problem on which we are working in the project.
 We describe the requirement specifications of the system and
the actions which can be done on these things.
 We understand the problem domain and produce a model of
the system, which describes operations that can be performed
on the system.
 We included features and operations in detail, including screen
layouts.
 We designed user interface and security issues related to
system.
 Finally, the system is implemented and tested according to test
cases.
Bibliography

1) Computer Science With Python – Sumitra Arora

2) google.com

3) slideshare.in

4) github.com
THANK YOU

You might also like