Project Report
Project Report
System in Python
1.Introduction
The Library Management System is a comprehensive
software application designed to efficiently manage library
operations. This Python-based system facilitates various
essential functions such as book borrowing, returning, adding
new books, and maintaining a detailed record of members. By
automating repetitive tasks, the system ensures enhanced
productivity, reduced manual errors, and user convenience for
both librarians and library members. The project aims to
modernize library management by integrating technology into
traditional processes.
2. Objectives
Automate routine library operations such as book
issuance, returns, and member registration.
Provide a user-friendly interface that caters to both
technical and non-technical users.
Enhance the efficiency, accuracy, and reliability of
library management tasks.
Ensure secure storage and easy retrieval of library data.
Enable seamless access to information about books and
members.
Features of the System
Book Management: Comprehensive functionalities to
add, update, delete, and search for books. Includes
tracking of book availability.
Member Management: Enables easy registration,
updates, and record maintenance for library members.
Borrowing and Returning: Streamlines the tracking of
issued books, due dates, and return processing.
Search Functionality: Advanced search options for
finding books by title, author, genre, or ISBN.
Report Generation: Automated generation of detailed
reports on issued books, overdue records, and overall
library statistics
Database Schema
The system’s database comprises three primary tables:
Books: Stores book details such as ISBN, title, author,
and availability status.
Members: Maintains records of library members,
including their name, contact details, and unique
membership ID.
Transactions: Logs every book issuance and return,
including member details, dates, and transaction IDs.
Advantages of the Program
Ease of Use: The user-friendly interface ensures that
both librarians and members can navigate the system
effortlessly.
Time Efficiency: Automating repetitive tasks like book
tracking and member management saves significant time
for library staff.
Accuracy: Reduces the chances of human errors in
record-keeping and transactions.
Scalability: The modular design allows for easy addition
of new features as library needs grow.
Cost-Effective: Built using free and open-source tools,
the system is a budget-friendly solution for libraries of
all sizes.
Enhanced Reporting: Provides detailed insights into
library operations through automated reports.
Security: Ensures secure data storage and minimizes the
risk of data loss through robust database management.
Customizability: Easily customizable to meet the
specific requirements of different libraries.
SOURCE CODE
import sqlite3
def connect_to_database():
try:
# Connect to the SQLite database (creates the file if it
doesn't exist)
conn = sqlite3.connect("library.db")
def add_book(conn):
try:
book_id = int(input("Enter Book ID: "))
title = input("Enter Book Title: ")
author = input("Enter Author Name: ")
publication_year = int(input("Enter Publication Year: "))
quantity = int(input("Enter Quantity: "))
cursor = conn.cursor()
cursor.execute(
"INSERT INTO books (book_id, title, author,
publication_year, quantity, is_rented) VALUES (?, ?, ?, ?, ?,
0)",
(book_id, title, author, publication_year, quantity)
)
conn.commit()
print("Book added successfully.")
except sqlite3.Error as e:
print("Error adding book:", e)
def view_books(conn):
try:
cursor = conn.cursor()
cursor.execute("SELECT * FROM books")
books = cursor.fetchall()
print("\nBooks in Library:")
print(f"{'ID':<10}{'Title':<30}{'Author':<30}
{'Year':<10}{'Quantity':<10}{'Rented':<10}")
print("-" * 100)
for book in books:
rented_status = "Yes" if book[5] else "No"
print(f"{book[0]:<10}{book[1]:<30}{book[2]:<30}
{book[3]:<10}{book[4]:<10}{rented_status:<10}")
except sqlite3.Error as e:
print("Error fetching books:", e)
def delete_book(conn):
try:
book_id = int(input("Enter Book ID to delete: "))
cursor = conn.cursor()
cursor.execute("DELETE FROM books WHERE
book_id = ?", (book_id,))
conn.commit()
if cursor.rowcount > 0:
print("Book deleted successfully.")
else:
print("Book not found.")
except sqlite3.Error as e:
print("Error deleting book:", e)
cursor = conn.cursor()
if result is None:
print(f"Book ID {book_id} not found.")
elif result[0] <= 0:
print(f"Book ID {book_id} is out of stock.")
elif result[1] == 1:
print(f"Book ID {book_id} is already rented.")
else:
cursor.execute("UPDATE books SET is_rented = 1,
quantity = quantity - 1 WHERE book_id = ?", (book_id,))
conn.commit()
print(f"Book ID {book_id} rented successfully.")
except sqlite3.Error as e:
print("Error renting books:", e)
except ValueError:
print("Invalid input. Please enter valid book IDs.")
cursor = conn.cursor()
cursor.execute("SELECT is_rented FROM books
WHERE book_id = ?", (book_id,))
result = cursor.fetchone()
if result is None:
print("Book not found.")
elif result[0] == 0:
print("Book is not rented.")
else:
cursor.execute("UPDATE books SET is_rented = 0,
quantity = quantity + 1 WHERE book_id = ?", (book_id,))
conn.commit()
print("Book returned successfully.")
except sqlite3.Error as e:
print("Error returning book:", e)
# Main menu
def main():
connection = connect_to_database()
if not connection:
print("Failed to connect to the database. Exiting...")
return
while True:
print("\nLibrary Management System")
print("1. Add Book")
print("2. View Books")
print("3. Delete Book")
print("4. Rent Books")
print("5. Return Book")
print("6. Exit")
if choice == "1":
add_book(connection)
elif choice == "2":
view_books(connection)
elif choice == "3":
delete_book(connection)
elif choice == "4":
rent_multiple_books(connection)
elif choice == "5":
return_book(connection)
elif choice == "6":
print("Exiting the program.")
connection.close()
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()
OUTPUT
Future Enhancements
Cloud Integration: Transitioning to cloud-based databases
to facilitate remote access and scalability.
Advanced Notifications: Introducing SMS or email
reminders for overdue books and due dates.
Mobile Application: Developing a companion mobile app
for easy access to library functionalities on the go.
Enhanced Reporting: Adding real-time dashboards and
visual analytics for better insights into library operations.
Book Reservations: Enabling members to reserve books
online, with automatic notifications upon availability.
BIBLIOGRAPHY