VELAMMAL VIDYALAYA,KARAMBAKKAM
COMPUTER SCIENCE INVESTIGATORY PROJECT
(2025-2026)
DESIGN AND
IMPLEMENTA
NAME: [Link] PRASATH
TION OF A
LIBRARY CLASS: XII-A
MANAGEMEN ROLLNUMBER:12A26
T USING
MYSQL AND
PYTHON
CERTIFICATE
This is to certify that E. SAI PRASATH of Class XII at Velammal Vidyalaya
Karambakkam has successfully completed the research on the below
mentioned project Design and Implementation of a Library Management
System Using Python and MySQL under the guidance of Ms. Arunachala
Vadivu B Computer Science Teacher during the year 2025–2026.
Signature of Signature of
Computer Science Principal
Teacher
Date:
Place: School Seal
ACKNOWLEDGEMENT
In the accomplishment of this project successfully, many people have
bestowed their blessings and heart pledged support upon me, I take this
opportunity to express my gratitude to all, who have been instrumental in
the success completion of this project.
Primarily, I express my deep sense of gratitude to the luminary, The
Correspondent, Shri. [Link] The Principal,
[Link] PREETHA MARY And Head Master
[Link] for providing the best of facilities and environment
to bring out innovation and spirit of inquiry through this venture
I am deeply indebted to my teacher Ms. ARUNACHALA
VADIVU B without whose constructive feedback, this project
would not have been successful. The valuable advice
and suggestions for correction, modifications and improvement
did enhance the quality of the task.
I would also like to thank my parents, friends and all the members who
contributed to this project was vital for the success of the project
I am grateful for their constant support and help
TABLE OF CONTENT
[Link] TITLE [Link]
1. INTORDUCTION 5-6
2. EXPECTED OUTCOMES 6
3. AIM 7
4. MAIN BODY OF PROGRAM 8-16
5. FUTURE SCOPE 17
6. Bibliography / References 18
Introduction:
2
In the digital age, the effective management of information has become a
cornerstone for the success and efficiency of all organizations, including
educational institutions. Libraries, being essential centers for learning,
research, and academic development, must adopt technological solutions to
streamline their operations and keep up with the increasing demands for
speed, accuracy, and accessibility. Traditional library management
practices, which rely heavily on paper-based systems or manual data entry,
are not only time-consuming but also prone to human errors and
inefficiencies. These limitations often lead to difficulties in tracking issued
books, maintaining updated member records, and managing return
deadlines, which can negatively impact user experience and staff
productivity.
To address these challenges, this project introduces a Library Management
System (LMS) developed using Python as the programming language and
MySQL as the backend relational database. This system is a command-line
application designed to automate and digitize core library functions such as
book cataloging, member registration, book issuing, returns, and fine
calculations. It offers librarians a simplified interface to manage daily
transactions effectively, thereby improving operational accuracy, reducing
the manual workload, and enhancing user satisfaction.
Python was chosen for its readability, flexibility, and broad range of built-in
libraries that support rapid application development. MySQL complements
it as a reliable and secure open-source database management system, ideal
for handling structured data and supporting multiple queries and
transactions efficiently. The combination of these technologies makes the
LMS both powerful and user-friendly.
The system’s architecture is modular, enabling future enhancements without
major restructuring. It incorporates robust logic to validate user input,
manage data consistency, and ensure secure data handling. Each function—
from adding a new book to calculating overdue fines—is designed with
clarity and maintainability in mind. This provides a solid foundation for
scaling the system to handle larger datasets or expanding it into a
networked, multi-user environment.
Ultimately, this project exemplifies how modern programming and database
technologies can be effectively leveraged to modernize traditional systems.
It demonstrates a scalable and reliable approach to transforming library
services and contributes to the ongoing digital transformation in the
3
education sector.
Expected Outcomes:
• A fully functional command-line system that automates daily library
operations.
• A MySQL database that reliably stores and retrieves book and member
data.
A codebase that can be used as a reference or starting point for further
development and learning.
4
Aim:
The main objective of this project is to design and implement a robust,
efficient, and user-friendly Library Management System (LMS) using
Python and MySQL. The system aims to automate core library operations,
reduce manual errors, and provide a reliable digital record of library
activities. The specific aims are:
1. Develop a Command-Line Application
• Provide a simple terminal-based interface for librarians to manage
essential library functions.
• Enable book management (add/view books), member management
(add/view members), book issuing, book returns, and overdue fine
calculation.
2. Maintain Reliable and Consistent Records
• Store all book and member information in a structured MySQL database.
• Track the status of each book (available or issued), the member who has
borrowed it, and the relevant dates.
3. Lay the Foundation for Future Enhancements
• Use a modular Python structure and a relational database to allow future
expansion, such as adding a graphical interface, reporting features, or
online access.
4. Educational Value
• Demonstrate how Python can interact with MySQL to create real-world
database applications.
• Encourage students to build upon this system for more advanced
projects.
5
Program:
import [Link]
import datetime
from [Link] import Error
db_config = None
def get_db_config():
"""Get MySQL configuration from user"""
print("\n=== MySQL Database Configuration ===")
config = {
'host': input("Enter MySQL host (default: localhost): ") or "localhost",
'user': input("Enter MySQL username: "),
'password': input("Enter MySQL password: "),
'database': input("Enter database name (default: library_db): ") or
"library_db"
}
return config
def initialize_database(config):
"""Creating database and tables """
try:
# Connect without specifying database first
connection = [Link](
host=config['host'],
user=config['user'],
password=config['password']
)
cursor = [Link]()
# Creating database
[Link](f"CREATE DATABASE IF NOT EXISTS
{config['database']}")
[Link] = config['database']
6
# Creating tables
[Link]("""
CREATE TABLE IF NOT EXISTS books (
book_id VARCHAR(20) PRIMARY KEY,
title VARCHAR(100) NOT NULL,
author VARCHAR(100) NOT NULL,
status VARCHAR(20) DEFAULT 'Available',
added_date DATE,
issued_to VARCHAR(20),
issue_date DATE,
due_date DATE
)
""")
[Link]("""
CREATE TABLE IF NOT EXISTS members (
member_id VARCHAR(20) PRIMARY KEY,
name VARCHAR(100) NOT NULL,
contact VARCHAR(100),
join_date DATE
)
""")
print("Database initialized successfully!")
return True
except Error as e:
print(f"Error initializing database: {e}")
return False
finally:
if 'connection' in locals() and connection.is_connected():
[Link]()
[Link]()
def create_connection():
"""Create database connection using user-provided config"""
global db_config
try:
connection = [Link](
host=db_config['host'],
7
user=db_config['user'],
password=db_config['password'],
database=db_config['database']
)
return connection
except Error as e:
print(f"Error connecting to MySQL: {e}")
return None
def add_book():
"""Add a new book to the library"""
conn = create_connection()
if conn is None:
return
cursor = [Link]()
book_id = input("Enter Book ID: ")
title = input("Enter Title: ")
author = input("Enter Author: ")
try:
[Link](
"INSERT INTO books (book_id, title, author, added_date)
VALUES (%s, %s, %s, %s)",
(book_id, title, author, [Link]())
)
[Link]()
print(f"Book {book_id} added successfully!")
except Error as e:
print(f"Error adding book: {e}")
finally:
[Link]()
[Link]()
def view_books():
"""View all books in the library"""
conn = create_connection()
if conn is None:
return
8
cursor = [Link](dictionary=True)
try:
[Link]("SELECT * FROM books")
books = [Link]()
print("\n===== Library Books =====")
for book in books:
print(f"ID: {book['book_id']}")
print(f"Title: {book['title']}")
print(f"Author: {book['author']}")
print(f"Status: {book['status']}")
if book['issued_to']:
print(f"Issued to: {book['issued_to']}")
print(f"Issue Date: {book['issue_date']}")
print(f"Due Date: {book['due_date']}")
print("-----------------------")
except Error as e:
print(f"Error viewing books: {e}")
finally:
[Link]()
[Link]()
def add_member():
"""Add a new library member"""
conn = create_connection()
if conn is None:
return
cursor = [Link]()
member_id = input("Enter Member ID: ")
name = input("Enter Name: ")
contact = input("Enter Contact: ")
try:
[Link](
"INSERT INTO members (member_id, name, contact, join_date)
VALUES (%s, %s, %s, %s)",
(member_id, name, contact, [Link]())
)
[Link]()
9
print(f"Member {member_id} added successfully!")
except Error as e:
print(f"Error adding member: {e}")
finally:
[Link]()
[Link]()
def view_members():
"""View all library members"""
conn = create_connection()
if conn is None:
return
cursor = [Link](dictionary=True)
try:
[Link]("SELECT * FROM members")
members = [Link]()
print("\n===== Library Members =====")
for member in members:
print(f"ID: {member['member_id']}")
print(f"Name: {member['name']}")
print(f"Contact: {member['contact']}")
print(f"Member Since: {member['join_date']}")
print("-----------------------")
except Error as e:
print(f"Error viewing members: {e}")
finally:
[Link]()
[Link]()
def issue_book():
"""Issue a book to a member"""
conn = create_connection()
if conn is None:
return
cursor = [Link](dictionary=True)
book_id = input("Enter Book ID to issue: ")
member_id = input("Enter Member ID: ")
10
try:
# Check if book exists and is available
[Link]("SELECT status FROM books WHERE book_id =
%s", (book_id,))
book = [Link]()
if not book:
print("Book not found!")
return
if book['status'] != 'Available':
print("Book is already issued!")
return
# Check if member exists
[Link]("SELECT * FROM members WHERE member_id =
%s", (member_id,))
if not [Link]():
print("Member not found!")
return
# Issue the book
due_date = [Link]() + [Link](days=14)
[Link](
"UPDATE books SET status = 'Issued', issued_to = %s, issue_date =
%s, due_date = %s WHERE book_id = %s",
(member_id, [Link](), due_date, book_id)
)
[Link]()
print(f"Book {book_id} issued to Member {member_id}")
print(f"Due Date: {due_date}")
except Error as e:
print(f"Error issuing book: {e}")
finally:
[Link]()
[Link]()
def return_book():
"""Return a book to the library with fine calculation"""
conn = create_connection()
11
if conn is None:
return
cursor = [Link](dictionary=True)
book_id = input("Enter Book ID to return: ")
try:
# Check book status and due date
[Link]("SELECT status, due_date FROM books WHERE
book_id = %s", (book_id,))
book = [Link]()
if not book:
print("Book not found!")
return
if book['status'] == 'Available':
print("Book was not issued!")
return
due_date = book['due_date']
today = [Link]()
days_overdue = (today - due_date).days if due_date else 0
fine = 0
if days_overdue > 0:
fine = days_overdue * 5 # ₹5 per day fine
[Link](
"UPDATE books SET status = 'Available', issued_to = NULL,
issue_date = NULL, due_date = NULL WHERE book_id = %s",
(book_id,)
)
[Link]()
if fine > 0:
print(f"Book returned late! Fine to pay: ₹{fine}")
else:
print("Book returned successfully with no fine.")
except Error as e:
print(f"Error returning book: {e}")
12
finally:
[Link]()
[Link]()
def main_menu():
"""Display main menu and handle user input"""
while True:
print("\n===== Library Management System =====")
print("1. Add Book")
print("2. View All Books")
print("3. Add Member")
print("4. View All Members")
print("5. Issue Book")
print("6. Return Book")
print("7. Exit")
choice = input("Enter your choice (1-7): ")
if choice == '1':
add_book()
elif choice == '2':
view_books()
elif choice == '3':
add_member()
elif choice == '4':
view_members()
elif choice == '5':
issue_book()
elif choice == '6':
return_book()
elif choice == '7':
print("Thank you for using the Library System!")
break
else:
print("Invalid choice! Please try again.")
def main():
global db_config
db_config = get_db_config()
13
if not initialize_database(db_config):
print("Failed to initialize database. Exiting...")
return
main_menu()
if __name__ == "__main__":
main()
14
OUTPUT:
IDLE (PYTHON 3.7)
15
MySQL DATA-BASE:
16
MySQL Database:
17
Future Scope:
While the current system efficiently manages the core needs of a small or
medium-sized library, it can be further enhanced in the following ways:
1. Graphical User Interface (GUI):
Develop a desktop interface using Tkinter or PyQt to make the system
more user-friendly, especially for non-technical users.
2. User Authentication:
Add login functionality with role-based access (e.g., admin vs. staff) to
improve security and control.
3. Web-Based Access:
Port the system to a web application using Flask or Django, allowing
remote access and online book reservations.
4. Notifications:
Integrate email or SMS reminders for due dates and overdue books to
improve user accountability.
5. Barcode/QR Code Integration:
Use barcode or QR code scanning for faster book and member
identification during issue/return operations.
6. Reporting and Analytics:
Add modules to generate reports on issued books, overdue returns, and
member activity, exportable as CSV or PDF.
7. Mobile App:
Develop a mobile app for Android or iOS to allow users and librarians to
access the system on the go.
These enhancements would further streamline library management,
improve user experience, and make the system suitable for larger or
more complex library environments.
This revised Aim and Future Scope accurately reflects the capabilities of your
current program and provides a realistic roadmap for future improvements.
18
Bibliography:
1. Python Documentation
[Link]
2. MySQL Connector/Python
[Link]
3. W3Schools MySQL Tutorial
[Link]
4. Real Python - Database Access in Python
[Link]
5. Geeks for Geeks Python MySQL Tutorial
[Link]
19