Library Management System Using Python
1) Background/ Problem Statement
A library is a place where a huge collection of books and resources are
available which can be accessible by the users. In traditional libraries,
the students have to search for books which is a hassle process and there
is no proper maintenance of the database about issues and fines. The
overall progress of work is slow and it is impossible to generate a fast
report. The librarians have to work allotted for arranging, and sorting
books in the book sales. At the same time, they have to check and
monitor the lent and borrowed book details with fine.
To tackle this problem, we have designed a Library Management
System using Python. Library management means efficient and
effective management of material (information sources), machinery,
men (human resources), technology and money to meet the objectives of
the library. Our system can help librarians to work easily. This
computerization of the library helps in many instances of its
maintenance. It reduces the workload of management as most of the
manual work done is reduced.
2) Working of the Project
Our Python-based project consists of two modules: Admin and User.
The admin can log in using their credentials. The admin can add, update,
view and delete any book and can also update the inventory. They can
also view orders by filtering the date, whether the books are returned or
not, and expired orders.
The user would need to register first to log in. They can manage their
profile and change their password. They can search for any book by
entering the book or author’s name. If they find the book they want,
they can issue it here. They can view the list of orders. They can also
return books. If any particular book is not returned within the given
period, the fine will be shown.
In this project, the front end involves Html, CSS and JavaScript and the
back end involves Python. The database: used is MySQL Database and
Django is used for the framework.
3) Advantages
The system is easy to maintain.
It is user-friendly.
The system excludes the use of paperwork by managing all the
records electronically.
Administrator doesn't have to keep a manual track of the users.
It saves human efforts and resources.
4) System Description
The system comprises 2 major modules with their sub-modules as
follows:
Admin:
● Login:
The admin can log in using their credentials.
● Manage Books:
They can add, update, delete and view any book in the system.
They can also update the inventory.
● View Orders:
The admin can view the orders by -
filter by date
filter by returned/not returned
filter by expired
User:
● Register:
The user would need to register to log in.
● Login:
The user can log in using their credentials.
● Profile:
They can manage and view their profile.
● Change Password:
The user can change their password if they want.
● Search Book:
The user can search for books by their name or author’s name.
If they find the book they want, they can issue it.
● View Orders:
The user can view the list of the book ordered.
They can return the book.
If a book is not returned within the period, a fine will be shown.
5) Project Life Cycle
The waterfall model is a classical model used in the system
development life cycle to create a system with a linear and sequential
approach. It is termed a waterfall because the model develops
systematically from one phase to another in a downward fashion. The
waterfall approach does not define the process to go back to the
previous phase to handle changes in requirements. The waterfall
approach is the earliest approach that was used for software
development.
6) System Requirements
I. Hardware Requirement
i. Laptop or PC
Windows 7 or higher
I3 processor system or higher
4 GB RAM or higher
100 GB ROM or higher
II. Software Requirement
ii. Laptop or PC
Python
Sublime Text Editor
XAMP Server
7) Limitations/Disadvantages
The information stored can be susceptible to cyber hacks.
Users cannot view the book in person
8) Application
This system can be used in public libraries to ease the work of
librarians and keep track of all the records.
9) Reference
https://www.researchgate.net/publication/347245735_Library_Management
_System
https://www.academia.edu/33632232/LIBRARY_MANAGEMENT_SYST
EM
https://www.academia.edu/37726542/Library_Management_System_Mini_
Project_Report_On_LIBRARY_MANAGEMENT_SYSTEM
https://www.startertutorials.com/uml/resources/lms/LMS6.pdf
https://www.daitm.org.in/wp-content/uploads/2019/04/Gr.-06library-project
-report.pdf
Source code:
import sqlite3
from tkinter import *
# Create database connection
conn = sqlite3.connect("library.db")
cursor = conn.cursor()
# Create tables
cursor.execute("""
CREATE TABLE IF NOT EXISTS books (
id INTEGER PRIMARY KEY,
title TEXT,
author TEXT,
status TEXT
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS members (
id INTEGER PRIMARY KEY,
name TEXT,
email TEXT
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS borrowings (
id INTEGER PRIMARY KEY,
book_id INTEGER,
member_id INTEGER,
borrow_date TEXT,
return_date TEXT
)
""")
# Commit changes
conn.commit()
class LibraryManagementSystem:
def __init__(self, root):
self.root = root
self.root.title("Library Management System")
# Create GUI components
self.notebook = Notebook(root)
self.notebook.pack(pady=10, expand=True)
self.frame1 = Frame(self.notebook)
self.frame2 = Frame(self.notebook)
self.frame3 = Frame(self.notebook)
self.notebook.add(self.frame1, text="Add Book")
self.notebook.add(self.frame2, text="Add Member")
self.notebook.add(self.frame3, text="Borrow Book")
# Add book frame
self.title_label = Label(self.frame1, text="Title:")
self.title_label.pack()
self.title_entry = Entry(self.frame1)
self.title_entry.pack()
self.author_label = Label(self.frame1, text="Author:")
self.author_label.pack()
self.author_entry = Entry(self.frame1)
self.author_entry.pack()
self.add_book_button = Button(self.frame1, text="Add Book", command=self.add_book)
self.add_book_button.pack()
# Add member frame
self.name_label = Label(self.frame2, text="Name:")
self.name_label.pack()
self.name_entry = Entry(self.frame2)
self.name_entry.pack()
self.email_label = Label(self.frame2, text="Email:")
self.email_label.pack()
self.email_entry = Entry(self.frame2)
self.email_entry.pack()
self.add_member_button = Button(self.frame2, text="Add Member", command=self.add_member)
self.add_member_button.pack()
# Borrow book frame
self.book_id_label = Label(self.frame3, text="Book ID:")
self.book_id_label.pack()
self.book_id_entry = Entry(self.frame3)
self.book_id_entry.pack()
self.member_id_label = Label(self.frame3, text="Member ID:")
self.member_id_label.pack()
self.member_id_entry = Entry(self.frame3)
self.member_id_entry.pack()
self.borrow_book_button = Button(self.frame3, text="Borrow Book", command=self.borrow_book)
self.borrow_book_button.pack()
def add_book(self):
title = self.title_entry.get()
author = self.author_entry.get()
cursor.execute("INSERT INTO books (title, author, status) VALUES (?, ?, 'Available')", (title, author))
conn.commit()
def add_member(self):
name = self.name_entry.get()
email = self.email_entry.get()
cursor.execute("INSERT INTO members (name, email) VALUES (?, ?)", (name, email))
conn.commit()
def borrow_book(self):
book_id = self.book_id_entry.get()
member_id = self.member_id_entry.get()
cursor.execute("SELECT * FROM books WHERE id = ?", (book_id,))
book = cursor.fetchone()
if book and book[3] == "Available":
cursor.execute("INSERT INTO borrowings (book_id, member_id, borrow_date) VALUES (?, ?, date('now'))", (book_id, member_id))
cursor.execute("UPDATE books SET status = 'Borrowed' WHERE id = ?", (book_id,))
conn.commit()
if __name__ == "__main__":
root = Tk()
library_management_system = LibraryManagementSystem(root)
root.mainloop()