0% found this document useful (0 votes)
26 views

Supriya

The document is a mini project report on a Library Management System developed using Python and MySQL, aimed at digitizing library operations for efficient management of books and borrowers. It includes sections on project objectives, system functionality, hardware and software requirements, and future enhancements, along with source code and user guide. The project was completed by Supriya Kumari under the guidance of Mr. Ravikant Sir at Langat Singh College, Muzaffarpur, Bihar.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Supriya

The document is a mini project report on a Library Management System developed using Python and MySQL, aimed at digitizing library operations for efficient management of books and borrowers. It includes sections on project objectives, system functionality, hardware and software requirements, and future enhancements, along with source code and user guide. The project was completed by Supriya Kumari under the guidance of Mr. Ravikant Sir at Langat Singh College, Muzaffarpur, Bihar.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

h College, Mu

ing zaff
S
ng at a

rp
La

ur
(Run under BRABU Bihar University)
A Mini Project Report on
Library Management System
For Python (502 and 506)

Name: Supriya Kumari


Roll: 23
University Roll: 226022
Session: 2022 – 25
Reg. No.: 133201119402322/22

Guided By: Mr. Ravikant Sir


Submitted to: Department of B.C.A., Langat Singh
College, Muzaffarpur, Bihar
Content

S.no. Content Page No.


1. Acknowledgement 1
2. Declaration 2
3. Project Report 3-4
4. Hardware and Software 5
Requirements
5. MySQL Schema 6
6. Project Scope 7
7. Future Enhancement 8
8. Method 9
9. User Guide 10-11
10. Source Code 12-17
11. Output 18
12. Testing 19-22
13. Maintenance 23
14. Bibliography 24
Acknowledgement

I would like to express my sincere gratitude to my Principal


Prof. Dr. O.P. Roy Sir and my Teacher Mr. Ravikant Sir for
their invaluable guidance, support, and encouragement
throughout the course of this project. Their expertise and
feedback have been instrumental in the completion of this
project.

I am also grateful to the officials of Department of B.C.A.,


Langat Singh College for providing the resources and
facilities needed to complete this work. My heartfelt thanks
go to my friends and family for their constant support and
motivation.

Lastly, I wish to thank everyone who contributed directly or


indirectly to the successful completion of this project.

Thank you.
Declaration
I, Supriya Kumari, hereby declare that the mini project entitled
"Library Management System" submitted in partial fulfilment of
the requirements for BCA at Langat Singh College, Muzaffarpur is
entirely my own work, conducted under the guidance of Mr.
Ravikant Sir.

I affirm that:
1. The contents of this project report are original and have not
been submitted, in part or in whole, for any other degree or
qualification.
2. Any sources of information used in this project report have
been properly acknowledged and referenced.
3. The experiments, analyses, and findings presented in this
report are genuine and have not been manipulated or falsified
in any manner.
4. Any assistance received from individuals or institutions
during the course of this project has been duly acknowledged.
I understand that any act of plagiarism or academic dishonesty in
this project would constitute a breach of academic integrity and
could lead to disciplinary action.

Supriya Kumari
Date:
Project Report:
Library Management System

Introduction:
The Library Management System is a software application
developed to handle day-to-day operations in a library. This
system provides a simple interface for managing books,
tracking issued and returned books, and maintaining a record
of borrowers. The main aim is to digitize the manual
process, making it more efficient and reliable.
▪ Objective:
• To provide a user-friendly platform to manage library
records efficiently.
• To enable easy tracking of books, including issuing,
returning, and managing their availability status.
• To maintain a record of borrowers and issued books to
avoid any discrepancies.

▪ Tools and Technologies:


• Programming Language: Python
• Database: MySQL
System Functionality:
Book Management Module
• This module allows administrators to:
• Add new books to the library collection.
• View all books and their availability status.
Borrower Management Module
• This module enables recording and management of
borrower information, including:
• Recording the name of the borrower and the ID of
the book borrowed.
• Removing borrower information when a book is
returned.
Issuing and Returning Module
• This module manages the process of issuing and
returning books:
• Updates the available status in the books table based
on issuing or returning actions.
• Keeps borrower information updated in the
borrowers table.
Hardware and Software
Requirements

Hardware Requirements:
• Processor: Intel Core i3 or above.
• RAM: 512 MB or higher.
• Hard Disk: 500 MB of Free space.

Software Requirements:
• Python 3.1.11 or above.
• MySQL Server.
• MySQL Connector Library (mysql.connector).
MySQL Schema
Database Creation:
CREATE DATABASE library_db;
USE library_db;

CREATE TABLE books (


book_id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
author VARCHAR(255),
available BOOLEAN DEFAULT TRUE
);

CREATE TABLE borrowers (


borrower_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
book_id INT, FOREIGN KEY (book_id) REFERENCES
books(book_id) ON DELETE SET NULL
);
Project Scope

Scopes:
• Book Management: Allows the addition of new books
to the library inventory and updates book availability.
• Borrower Management: Keeps a record of borrowers,
including which books they have borrowed.
• Book Issuing and Returning: Manages the process of
issuing and returning books, ensuring availability status
updates.
Limitations:
• Local Application: The current implementation is
intended for local use only, as the database is hosted
locally and the application runs as a desktop application.
• Scalability: Designed for small to medium-sized rental
agencies. To support a larger scale with more
transactions, the application would require optimization
and potential migration to a cloud-based database.
• Customer Management: The current scope does not
include comprehensive customer management or user
authentication. It focuses primarily on the vehicle rental
process.
Future Enhancement

Add Search Functionality:


Implement a search feature to filter books based on title,
author or genre.

Enhance UI Design:
Improve the user interface with a better layout and
styling using frameworks like ttk for a more modern
look.

Add Reporting:
Generate reports of borrowed books, late returns, etc.
User Management:
Allow role-based access for library staff and members.
Method

Database Connection:
• Implementing MySQL queries to insert, update, and
fetch data.
• Using SQL queries for managing book availability and
recording rental details.
Core Functions:
• create_tables(): Initializes the database tables if they do
not already exist.
• add_book(): Adds a new book to the library database.
• view_books(): Displays the list of all books with their
availability.
• issue_book(): Issues a book to a borrower and updates
the available status.
• return_book(): Marks a book as returned and removes
the borrower record.
User Guide
Installation:
1. Ensure that Python 3.1.11 or above is installed on your
system.
2. Install the required libraries using pip:
pip install mysql-connector-python
3. Set up the MySQL database:
• Create a database named library_db.
• Execute the provided SQL schema to create the
necessary tables.
4. Download and run the application script.
Getting Started:
Launching the Application:
1. Run the Python script using the following command in
your terminal or command prompt:
python library_app.py

Using the System:


Adding Book:
• Select the "Add Book" option from the menu.
• Enter the book title when prompted.
• Enter the author’s name.
• The system will confirm that the book has been added
successfully.

Viewing Books:
• Select the "View Books" option from the menu.
• The system will display a list of all books, showing:
o Book ID
o Title
o Author
o Availability (Yes/No).

Issuing Books:
• Select the "Issue Book" option from the menu.
• Enter the Book ID of the book to be issued.
• Enter the borrower's name.
• The system will update the book's availability and
confirm the book has been issued.
Returning Books:
• Select the "Return Book" option from the menu.
• Enter the Book ID of the book being returned.
• The system will mark the book as available and remove
the borrower’s record.
• A confirmation message will be displayed..
Source Code

import mysql.connector

# Establish connection to MySQL


conn = mysql.connector.connect(
host="localhost",
user="root",
password="supriya@23",
database="library_db"
)
cursor = conn.cursor()

# Function to create tables


def create_tables():
cursor.execute("""
CREATE TABLE IF NOT EXISTS books (
book_id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
author VARCHAR(255),
available BOOLEAN DEFAULT TRUE
)""")

cursor.execute("""
CREATE TABLE IF NOT EXISTS borrowers (
borrower_id INT AUTO_INCREMENT PRIMARY
KEY,
name VARCHAR(255) NOT NULL,
book_id INT,
FOREIGN KEY (book_id) REFERENCES
books(book_id)
)""")
conn.commit()
print("Tables created successfully.")

# Function to add a new book


def add_book(title, author):
cursor.execute("INSERT INTO books (title, author)
VALUES (%s, %s)", (title, author))
conn.commit()
print("Book added successfully.")
# Function to view all books
def view_books():
cursor.execute("SELECT * FROM books")
for (book_id, title, author, available) in cursor.fetchall():
print(f"ID: {book_id}, Title: {title}, Author: {author},
Available: {'Yes' if available else 'No'}")

# Function to issue a book


def issue_book(book_id, borrower_name):
cursor.execute("SELECT available FROM books
WHERE book_id = %s", (book_id,))
result = cursor.fetchone()

if result and result[0]: # Check if book is available


cursor.execute("UPDATE books SET available =
FALSE WHERE book_id = %s", (book_id,))
cursor.execute("INSERT INTO borrowers (name,
book_id) VALUES (%s, %s)", (borrower_name, book_id))
conn.commit()
print("Book issued successfully.")
else:
print("Book is not available.")
# Function to return a book
def return_book(book_id):
cursor.execute("SELECT borrower_id FROM borrowers
WHERE book_id = %s", (book_id,))
result = cursor.fetchone()

if result:
cursor.execute("DELETE FROM borrowers WHERE
book_id = %s", (book_id,))
cursor.execute("UPDATE books SET available =
TRUE WHERE book_id = %s", (book_id,))
conn.commit()
print("Book returned successfully.")
else:
print("No record of this book being issued.")

# Main program
if __name__ == "__main__":
create_tables()
while True:
print("\nLibrary Management System")
print("1. Add Book")
print("2. View Books")
print("3. Issue Book")
print("4. Return Book")
print("5. Exit")
choice = input("Enter your choice: ")

if choice == '1':
title = input("Enter book title: ")
author = input("Enter author name: ")
add_book(title, author)

elif choice == '2':


view_books()

elif choice == '3':


book_id = int(input("Enter book ID to issue: "))
borrower_name = input("Enter borrower name: ")
issue_book(book_id, borrower_name)

elif choice == '4':


book_id = int(input("Enter book ID to return: "))
return_book(book_id)

elif choice == '5':


print("Exiting...")
break

else:
print("Invalid choice. Please try again.")

# Close the connection


cursor.close()
conn.close()
Output
Testing

1. MySQL (Just after Creation):

2. Add book:
3. Book table:

4. View available Books:


5. Issue Book:
6. Return Book:
Maintenance

Database Maintenance:
• Backup Regularly
• Data Optimization
• Data Validation
Code Maintenance:
• Use Version Control
• Update Libraries
• Handle Errors
Security:
• Database Security
• Application Security
Bug Fixes and Updates:
• Fix Bugs Quickly
• Test New Features
• User Feedback Monitoring
Bibliography

MySQL Connectivity in Python:


https://www.w3schools.com/python/python_mysql_
getstarted.asp

You might also like