AMRITA VIDYALAYAM SENIOR
SECONDARY SCHOOL Managed by MATA
AMRITANANDAMAYI MATH.
DEPARTMENT OF
COMPUTER SCIENCE
2022-2023
TOPIC
LIBRARY MANAGEMENT SYSTEM
AMRITA VIDYALAYAM
SENIOR SECONDARY SCHOOL Managed by
MATA AMRITANANDAMAYI MATH
Certificate
This is to certify that Master S. YUKESH of Class: XII Section: ____ Register No.
________________ has completed his Investigatory project in the subject of COMPUTER
SCIENCE as required according to the Central Board of Secondary Education for the
academic session 2022-2023.
Date: Teacher in charge Examiner’s Signature: Principal
ACKNOWLEDGEMENT
I would like to convey my thanks to my Computer Science teacher Smt.
G. Thiriburasundari of Amrita Vidyalayam, Pondicherry for her
immense help and guidance in the completion of my project.
I would like to convey my thanks to our school principal Shri. S.
Rajasekar and our school management for providing necessary
materials.
I would like to extend my gratitude for everyone who helped me to
complete this project.
NAME OF THE STUDENT: S. YUKESH
REGISTER NO: ___________________
A PROJECT ON
COMPUTER SCIENCE
TOPIC:
LIBRARY MANAGEMENT SYSTEM
DONE BY:
SRIRAM. V
H. SHANJAI CUMAR
S. YUKESH
CONTENTS
Abstract ........................................................................................................................................ 01
Introduction .................................................................................................................................. 01
Requirements ................................................................................................................................ 02
Hardware configuration ........................................................................................................ 02
Software configuration .......................................................................................................... 03
Installation/Configuration ............................................................................................................ 03
Structure ....................................................................................................................................... 04
Database ................................................................................................................................ 04
Tables .................................................................................................................................... 04 The
manual ................................................................................................................................... 05
Source code .................................................................................................................................. 06
Sample output ............................................................................................................................... 13
Starting window .................................................................................................................... 13
Viewing all book’s information ............................................................................................. 13 Add
a new book .................................................................................................................... 14 Remove
an old book ............................................................................................................. 14 Modify some
updated information of a book ........................................................................ 14 Close the program
................................................................................................................. 15 Lend or borrow a
book .......................................................................................................... 15Return borrowed
books ......................................................................................................... 15 To view history and
current status of lend books .................................................................. 15 Reference
links ............................................................................................................................. 16
Library Management System
A.Abstract
Library management system is a program that is designed to
manage all the functions of a library. It helps librarian to maintain
the database of new books and the books that are borrowed by
members along with their due dates.
This system completely automates all your library’s activities. The
best way to maintain, organize, and handle countless books
systematically is to implement a library management system
program.
B. Introduction
A library management system is used to maintain library records. It
tracks the records of the number of books in the library, how many
books are issued, or how many books have been returned or
renewed or late fine charges, etc.
You can find books in an instant, ‘all books’ quickly, and manage
all the data efficiently and orderly using this system. The purpose of
a library management system is to provide instant and accurate data
regarding any type of book, thereby saving a lot of time and effort.
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, cataloguing, 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.
1
The library management system software helps in reducing
operational costs. Managing a library manually is labour 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 records is a simple process.
Stock checking and verification of books in the library can be done
within a few minutes. The automated system saves a considerable
amount of time as opposed to the manual system.
The library management system software makes the library a smart
one by organizing the books systematically by author, title and
subject. This enables users to search for books quickly and
effortlessly.
C.Requirements
I. Hardware configuration :
Memory usage - Less than 2 GB or even more if required.
Storage - The program is of approx. 40MB, but it is preferable to
have at least 8GB of internal
storage.
Processor - Any processing unit running on 32 or 64 Bit and
more than 2.5 GHz.
2
II. Software configuration :
Operation system - Any os can be used most preferable is
Windows 7 or higher and mac os (using
source code).
Python - Any version of python but greater than 3. Database -
MySQL version 5 or 8 and even higher.
D.Installation/Configuration
For a ready application or clean use, direct to the folder (Library
Management System) which contains an executable file (Library
Management-System.exe). Before running the system, locate a file
called “config.txt” and enter some required information like
database host ip, username and its password.
Configuration file: config.txt
a)root – It’s the username for database, which maybe changes
person to person based on which you used in setup of MySQL
server.
b)here – This is where you have to type your password by replacing
it.
3
Maybe you are a developer or a student keen to explore how the
system works, so you can redirect to folder named “Source Code”.
Inside that, the original source code in form of a python file
(Library_Management_System.py) exists, its configuration file
(config.txt), make use of above instruction for the configuration file.
A special file called “requirements.txt” is used to make all the
installation at one go if you are using a virtual environment in order
to run this code use this command to get the installation done.
pip install –r requirements.txt
Note: Make use of all the README.txt files in order to redirect
back on the path, (It is available at different folders where it is
necessary).
E. Structure
a.Database: library
This is where all the information of books are stored in the form of
tables.
b.Tables:
1. all_books – Once a book is newly arrived or an old book is
been removed from the library, those data will be entered in
this table i.e. actions like adding, updating and removing
books.
4
2. borrowed_books – Here, the entire borrowed book’s
information are stored. If a reader takes a book out of the
library, it is been registered by the librarian into this table
where current time, name of the person and title of the book
are collected.
F. The Manual
There are eight features in this library management system; each
consists of its own action number and name. Every time you open
the program or switch from one feature to another these eight will
display so that you verify without any confusion.
5
The Features:
all books (1) Show all the book available/registered.
insert (2) To add a new book.
delete (3) Remove a book from the register.
update (4) Can change any book's information.
exit (5) Quit/exit the program.
lend book (6) Take a book from the library.
return book (7) Give a borrowed book back.
all lend (8) Show all the lends and its information.
The keywords at the starting of each line are called action name and
those numbers present inside the bracket are known as action
numbers, about these actions it is given very shortly at right end of
each line.
If any task has to be done, you can either enter its respective action
name or number at given space.
G.Source code
This source code has its own format of display, it is a print format
of official python IDLE.
6
import mysql
import mysql.connector as sqlconn
from tabulate import tabulate
from colorama import Fore, Style
import time
import colorama
colorama.init()
with open("config.txt", "r") as file_object:
data = file_object.read().split()
USERNAME = data[1]
PASSWORD = data[3]
HOST = data[5]
DATABASE_NAME = "library"
TABLE_NAME_01 = "all_books"
TABLE_NAME_02 = "borrowed_books"
print("[LMS] Starting...")
print("[LMS] Requesting access")
myconn = sqlconn.connect(host=HOST, username=USERNAME,
passwd=PASSWORD) mycursor = myconn.cursor()
print("[LMS] Connected and running...")
mycursor.execute(f"CREATE DATABASE IF NOT EXISTS
{DATABASE_NAME}") mycursor.execute(f"USE {DATABASE_NAME}")
mycursor.execute(f"CREATE TABLE IF NOT EXISTS {TABLE_NAME_01}(id
char(120) NOT NULL, name varchar(120) NOT NULL, genre varchar(100),
author varchar(100), publication varchar(100))")
mycursor.execute(f"CREATE TABLE IF NOT EXISTS {TABLE_NAME_02}(id
char(120) NOT NULL, person_name varchar(120) NOT NULL, book_name
varchar(120) NOT NULL, borrow_dt timestamp NOT NULL, return_dt
timestamp NOT NULL)")
myconn.commit()
def checkID(id):
queryCID = f"SELECT EXISTS(SELECT id FROM {TABLE_NAME_01} WHERE
id='{id}')" mycursor.execute(queryCID)
outputCID = mycursor.fetchall()
if outputCID[0][0] != 0:
outputcid = True
else:
outputcid = False
return outputcid
def checkName(name):
queryCN = f"SELECT EXISTS(SELECT name FROM {TABLE_NAME_01} WHERE
name='{name}')"
mycursor.execute(queryCN)
outputCN = mycursor.fetchall()
if outputCN[0][0] != 0:
outputcn = True
else:
outputcn = False
7
return outputcn
def checkBorrowedBook(IDC, PNC, BNC):
queryCBB = f"SELECT EXISTS(SELECT id, person_name, book_name FROM
{TABLE_NAME_02} WHERE id='{IDC}' && person_name='{PNC}' &&
book_name='{BNC}')" mycursor.execute(queryCBB)
outputCBB = mycursor.fetchall()
if outputCBB[0][0] != 0:
outputcn = True
else:
outputcn = False
return outputcn
def view_all_books():
queryVAB = f"SELECT * FROM {TABLE_NAME_01}"
mycursor.execute(queryVAB)
outputvab = mycursor.fetchall()
outputVAB = tabulate(outputvab, headers=["ID", "NAME", "GENRE",
"AUTHOR", "PUBLICATION"], tablefmt="psql")
return outputVAB
def insert_book(intupleIB):
queryIB = f"INSERT INTO {TABLE_NAME_01} VALUES{intupleIB}"
try:
mycursor.execute(queryIB)
myconn.commit()
putout1 = Fore.LIGHTGREEN_EX + "Added a new book
successfully." + Style.RESET_ALL
except mysql.connector.errors.IntegrityError:
putout1 = Fore.RED + "Problem identified, try again with correct
information." + Style.RESET_ALL
return putout1
def delete_book(DCFB):
queryDB = f"DELETE FROM {TABLE_NAME_01} WHERE {DCFB}"
CBA1 = len(view_all_books())
mycursor.execute(queryDB)
myconn.commit()
CBA2 = len(view_all_books())
if CBA1 == CBA2:
outputDB = Fore.RED + "No book is deleted, if your changes
isn't taken place try again with proper information" + Style.RESET_ALL
else:
outputDB = Fore.LIGHTGREEN_EX + "One book is successfully
deleted." + Style.RESET_ALL
return outputDB
def update_book(NV, UCFB):
queryUB = f"UPDATE {TABLE_NAME_01} SET {NV} WHERE {UCFB}"
mycursor.execute(queryUB)
myconn.commit()
return mycursor.fetchall()
8
def lend_book(idlb, pN, bN):
RDT = "0000-00-00 00:00:00"
if checkID(idlb) and checkName(bN):
mycursor.execute("SELECT CURRENT_TIMESTAMP")
BDT = mycursor.fetchall()[0][0]
queryLB = f"INSERT INTO {TABLE_NAME_02} VALUES('{idlb}', '{pN}', '{bN}',
'{BDT}', '{RDT}')"
mycursor.execute(queryLB)
myconn.commit()
outputlb = mycursor.fetchall()
if not outputlb:
outputLB = Fore.LIGHTGREEN_EX + "Successfully add a book into borrow list." +
Style.RESET_ALL
else:
outputLB = Fore.RED + "Problem identified. Recheck your entry and try again." +
Style.RESET_ALL
else:
outputLB = Fore.RED + "Enter valid id or name." + Style.RESET_ALL return
outputLB
def return_book(idrb, pN, bN):
if checkID(idrb) and checkName(bN) and checkBorrowedBook(idrb, pN, bN):
mycursor.execute("SELECT CURRENT_TIMESTAMP")
NRDT = mycursor.fetchall()[0][0]
queryRB = f"UPDATE {TABLE_NAME_02} SET return_dt='{NRDT}' WHERE
id='{idrb}' && person_name='{pN}' && book_name='{bN}'"
mycursor.execute(queryRB)
myconn.commit()
outputrb = mycursor.fetchall()
if not outputrb:
outputRB = Fore.LIGHTGREEN_EX + "Successfully returned a book." +
Style.RESET_ALL
else:
outputRB = Fore.RED + "Problem identified. Recheck your entry and try again." +
Style.RESET_ALL
else:
outputRB = Fore.RED + "Enter valid id, person name or book name." +
Style.RESET_ALL
return outputRB
def all_lends():
queryAL = f"SELECT * FROM {TABLE_NAME_02}"
mycursor.execute(queryAL)
outputal = mycursor.fetchall()
outputAL = tabulate(outputal, headers=["ID", "PERSON NAME", "BOOK NAME",
"BORROW TIME/DATE", "RETURN TIME/DATE"], tablefmt="psql")
return outputAL
#aimrrs
print("Welcome to the Library Management system!")
condition = True
while condition:
print(Fore.YELLOW + "\nFor execution, type the corresponding action number 9
when required." + Style.RESET_ALL)
print(Fore.YELLOW + "Note all entries should not contain any extra
character or whitespaces." + Style.RESET_ALL)
print("all books (1) Show all the book
available/registered.") print("insert (2) To add a new
book.")
print("delete (3) Remove a book from the register.")
print("update (4) Can change any book's information.")
print("exit (5) Quit/exit the program.")
print("lend book (6) Take a book from the library.")
print("return book (7) Give a borrowed book back.")
print("all lend (8) Show all the lends and its information.\
n") N = input("Enter action number: ")
if N == "1" or N.lower() == "all books":
output01 = view_all_books()
print(output01)
elif N == "2" or N.lower() == "insert":
i1 = input("Enter book's id: ")
i2 = input("Enter book's name: ")
i3 = input("Enter book's genre: ")
i4 = input("Enter book's author: ")
i5 = input("Enter book's publication: ")
if i1 and i2 and i3 and i4 and i5:
if not checkID(i1):
intupleib = (i1, i2, i3, i4, i5)
output02 = insert_book(intupleib)
print(output02)
else:
print(Fore.RED + "Id already exists, to verify use 'all books'
or action number 1." + Style.RESET_ALL)
else:
print(Fore.RED + "Enter valid information for all the required
entries." + Style.RESET_ALL)
elif N == "3" or N.lower() == "delete":
delete_method = input("Delete by book's id or name: ")
if delete_method.lower() == "id":
deleteCon = input("Enter book's id: ")
ICFB = f"id='{deleteCon}'"
output03 = delete_book(ICFB)
print(output03)
elif delete_method.lower() == "name":
deleteCon = input("Enter book's name: ")
ICFB = f"name='{deleteCon}'"
output03 = delete_book(ICFB)
print(output03)
else:
print(Fore.RED + "Try to enter valid command. Did you mean
'id' or 'name' to type in." + Style.RESET_ALL)
elif N == "4" or N.lower() == "update":
UCFB = None
10
while not UCFB:
update_method = input("Update book's information by its id
or name or both: ")
if update_method.lower() == "id":
updateCon = input("Enter books's id: ")
if checkID(updateCon):
UCFB = f"id='{updateCon}'"
else:
print(Fore.RED + "Invalid id!" + Style.RESET_ALL)
elif update_method.lower() == "name":
updateCon = input("Enter books's name: ")
if checkName(updateCon):
UCFB = f"name='{updateCon}'"
else:
print(Fore.RED + "Invalid name!" + Style.RESET_ALL)
elif update_method.lower() == "both":
updateCon1 = input("Enter books's id: ")
updateCon2 = input("Enter books's name: ")
if checkID(updateCon1) and checkName(updateCon2):
UCFB = f"id='{updateCon1}' && name='{updateCon2}'"
else:
print(Fore.RED + "Invalid id or name!" + Style.RESET_ALL)
else:
print(Fore.RED + "Try to enter valid command, did you mean 'id'
or 'name' or 'both' to type in." + Style.RESET_ALL)
keys = ["name", "genre", "author", "publication"]
i = 0
updateKey = None
while i != len(keys) and i<len(keys):
updateKeys = input(f"Do you want to change book's {keys[i]}
(yes/no): ")
if updateKeys.lower() == "no":
i+=1
elif updateKeys.lower() == "yes":
updateKey = keys[i]
break
else:
print(Fore.RED + "Try to enter valid command, did you
mean 'yes' or 'no' to type in." + Style.RESET_ALL)
if updateKey:
UNVFB = input(f"Enter new {updateKey}: ")
NV = f"{updateKey}='{UNVFB}'"
outputUB = update_book(NV, UCFB)
if not outputUB:
output04 = Fore.GREEN + "Successfully updated new information.
Review it by using action name 'all books'." + Style.RESET_ALL
else:
output04 = Fore.GREEN + "Problem identified, try again." +
Style.RESET_ALL
print(output04)
elif N == "5" or N.lower() in ["exit", "quit"]:
print("[LMS] quiting...")
print("[LMS] program shutdown.\n")
11
condition = False
time.sleep(2.5)
elif N == "6" or N.lower() == "lend book":
id = input("Enter book's id: ")
person_name = input("Enter person's name: ")
book_name = input("Enter book's name: ")
output06 = lend_book(id, person_name, book_name)
print(output06)
elif N == "7" or N.lower() == "return book":
id = input("Enter book's id: ")
person_name = input("Enter person's name: ")
book_name = input("Enter book's name: ")
output07 = return_book(id, person_name, book_name)
print(output07)
elif N == "8" or N.lower() == "all lends":
output08 = all_lends()
print(output08)
else:
print(Fore.RED + "Invalid action/action number. Recheck your
entry and try again." + Style.RESET_ALL)
12
H.Sample output
1. Starting window:
2. Viewing all book’s information:
13
3. Add a new book:
4. Remove an old book:
5. Modify some updated information of a book:
14
6. Close the program:
7. Lend or borrow a book:
8. Return
the borrowed book:
9. To view
history and current status of lend books:
15
I. Reference links
These links are referred only for content writing, it is not related to
any of the source code or sample output given in this document.
https://www.skoolbeep.com/blog/library-management-system/
https://www.iitms.co.in/library-management-system/
https://templatelab.com/table-of-contents-templates/
“Sometimes it is the people no one can imagine anything of
who do the things no one can imagine.”
Alan Turing
“Measuring programming progress by lines of code is like
measuring aircraft building progress by weight.”
Bill Gates
16