0% found this document useful (0 votes)
14 views22 pages

Cs Ritvik Project Final

Uploaded by

midaye4648
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)
14 views22 pages

Cs Ritvik Project Final

Uploaded by

midaye4648
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/ 22

VELAMMAL VIDYALAYA KARAMBAKKAM

COMPUTER SCIENCE INVESTIGATORY PROJECT


(2024-2025)

NAME: S.S.J RITVIK

CLASS: XII-A
ROLL NUMBER:

1
CERTIFICATE

This is to certify that S.S.J RITVIK


studying in class XII at Velammal Vidyalaya Karambakkam has
successfully completed the research on the below mentioned project
LIBRARY MANAGEMENT under the guidance of
Ms.B.ARUNACHALA VADIVU ,Computer science Teacher in the year
2024-2025.

Signature of Computer science Teacher Signature of Principal

Signature of Internal Examiner Signature of External Examiner

Date:

Place: School Seal

2
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.M.V.M.VELMOHAN,The Principal,
Ms.ANNE PREETHA MARY, And Head Master
Mr.K.PANNEER SELVAM 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 Mr.K.PANNEER SELVAM, 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

3
INDEX
S.NO TOPIC PAGE.NO

1 INTRODUCTION 5

2 WHY PYTHON? 5-6

3 WHY MYSQL? 7-9

4 OBJECTIVES OF THE PROJECT 9

5 DATABASE DESIGN 9

6 IMPLEMENTATION 10

7 SOURCE CODE 11-14

8 OUTPUT 15-20

9 CONCLUSION 21

10 BIBLIOGRAPHY 22

4
LIBRARY MANAGEMENT SYSTEM

INTRODUCTION

Libraries are essential hubs of knowledge, providing access to books,


resources, and information. As technology advances, managing a library's vast
collection and keeping track of transactions has becomemore complex. A
Library Management System (LMS) offers a solutionby automating the
process of managing books, members, and transactions. This project aims to
develop a Library Management System using Python and MySQL, which will
help librarians and administrators efficiently manage the library's resources.

WHY PYTHON?

Python is a high-level, interpreted, and general-purpose programming


language. It is known for its simplicity and readability, making it a popular
choice for both beginners and experienced developers. Python supports
various programming paradigms, including object-oriented, procedural, and
functional programming, which makes it versatile for different kinds of
projects.

 Simplicity
 Flexibility
 Extensive Libraries

Why Use Python for the Library Management System?

Python is an ideal choice for building a Library Management System due


to several factors:

5
1. Ease of Development:

 Python’s simple syntax allows developers to quickly build the necessary


logic for managing books, members, and transactions without worrying
about complex code structures.
 This makes Python a great language for students or developers who are
building projects with a focus on functionality and efficiency.

2. Database Connectivity with MySQL:

 Python provides robust libraries like mysql-connector-python that allow


easy interaction with MySQL databases. This makes it convenient to store
and retrieve data, such as book details, member information, and
transaction records.

 Using Python, you can easily execute SQL queries and manage large datasets
without complex configuration.

3. Cross-Platform Support:

 Python runs on various platforms (Windows, macOS, Linux), allowing the


project to be easily deployed on different systems. This flexibility is
essential for small to medium-sized applications that might need to be
deployed in different environments.

Advantages of Python in This Project

 Readable Code: Python’s syntax is beginner-friendly and emphasizes


readability, which helps make the code for the Library Management
System clean and easy to understand.

 Built-in Libraries: Python comes with numerous libraries and modules


that simplify common tasks like database connection, data manipulation,
and file handling.

 Scalability: The system can easily be scaled up as the library grows. New
features like an online catalog, member notifications, and book
reservations can be integrated seamlessly with Python.

 Integration with MySQL: Python’s ability to work with MySQL databases


makes it a perfect fit for storing data such as book records and
transaction details.

6
WHY MYSQL?

MySQL is a popular open-source Relational Database Management System


(RDBMS) that uses Structured Query Language (SQL) to manage and
manipulate databases. It is widely used for managing structured data, making it
ideal for applications that require data storage, retrieval, and organization, like
a Library Management System.
Why Use MySQL for the Library Management System?

MySQL is a great choice for managing the data in a Library Management System
for several reasons:

1. Data Storage and Management

In a library system, you need to store and manage large amounts of data, such as:

 Book Information: Titles, authors, availability, and categories.


 Member Details: Member names, IDs, contact details.
 Transactions: Borrowing and returning books, due dates, and fines.

MySQL helps efficiently manage this data by:

 Organizing data into tables with rows and columns, making it easy to
retrieve and update.
 Maintaining Relationships between different data entities (e.g., books,
members, transactions) using foreign keys, ensuring data consistency.

2. Structured Query Language (SQL)

SQL is the language used to interact with MySQL databases. It allows you to
perform operations such as:

 Insert new data (e.g., add new books, members).


 Update existing records (e.g., update book availability when borrowed).
 Delete records (e.g., remove outdated or lost books).
 Retrieve data (e.g., search for available books, track borrowing history).

3. Reliability and Consistency

Libraries require that data, such as book availability and member transactions, be
handled reliably and accurately. MySQL provides:

 Data Integrity: Ensures that the data stored is accurate and consistent. For
example, a book cannot be borrowed if it is already issued.
7
4. Scalability

As the library grows, so will the data. MySQL can handle large amounts of data
efficiently, making it easy to scale the system when new records (e.g., books,
members, transactions) are added. Whether the system is used by a small library
or a larger institution, MySQL can accommodate growing databases.

5. Multi-User Support

In a real-world library system, multiple users (e.g., librarians, administrators)


might access and update the system simultaneously. MySQL:

 Supports multiple concurrent connections, meaning different staff can


use the system at the same time without data conflicts.
 Provides user access control by allowing administrators to set different
permission levels for various users, ensuring data security and access
control.

6. Security Features

Security is critical when dealing with sensitive information, such as member


details or book transactions. MySQL provides:

 User authentication: Only authorized users can access the database.


 Access controls: Specific permissions (read, write, modify) can be assigned
to different users based on their role in the library.
 Encryption: Data can be encrypted to ensure secure storage and transfer
of sensitive information.

7. Open-Source and Free

MySQL is an open-source database management system, meaning it’s free to use.


This makes it a cost-effective solution for building a Library Management System,
especially for small to medium-sized libraries.

8. Integration with Python

MySQL can easily integrate with Python using libraries like mysql-connector-
python This allows:

 Easy interaction between Python and the database: Python can send
SQL queries to MySQL to retrieve or modify data.
 Automation: Python scripts can automate tasks such as generating reports,
updating book records, or notifying members about due dates.
8
Advantages of Using MySQL in the Library Management System

1. Efficient Data Storage: MySQL can handle structured data, such as books
and member details, efficiently.
2. Fast Data Retrieval: MySQL allows for quick searches and retrievals of
data, such as finding available books or a member's borrowing history.
3. Transaction Management: The system ensures that actions such as
borrowing and returning books are recorded accurately, preventing issues
like overbooking.
4. Data Relationships: MySQL allows you to define relationships between
tables (books, members, transactions), making it easy to link data and
maintain consistency.

OBJECTIVES OF THE PROJECT

 To automate the process of managing books, including adding,


updating, and deleting book records.
 To manage library members' information, allowing for easytracking
of memberships.
 To facilitate the borrowing and returning of books, ensuring
accurate tracking of transactions.
 To provide an easy-to-use interface for library staff to manage day-to-day
operations.

DATABASE DESIGN
The system uses a relational database to store information about books,
members, and transactions. The database consists of threemain tables:

1. Books Table: Stores information about each book, including its ID,title,
author, and availability status.

2. Members Table: Stores information about library members,


including their ID and name.

3. Transactions Table: Records each book borrowing and returning


transaction, linking books and members.

9
IMPLEMENTATION
Back end: Python
Database: MySQL
Connector: MySQL Connector for Python

Adding a New Book


This feature allows librarians to add new books to the system. The
book's title, author, and availability status are recorded in the
database.

Viewing Available Books


Librarians and members can view the list of available books. This
feature retrieves and displays all books from the database that are
marked as available.

Adding a New Member


New members can be added to the library by recording their personal
details in the system. This feature stores the member's name and
assigns a unique member ID.

Borrowing a Book
When a member borrows a book, the system checks if the book is
available, updates the availability status, and records the transaction
in the database.

Returning a Book
When a book is returned, the system updates the book's availability
status and records the return date in the transaction table

FUTURE ENHANCEMENTS

Online Catalog: Allow members to search for books and check


availability online.
Reservation System: Enable members to reserve books that are
currently checked out.
Advanced Reporting: Develop reports for library administrators to
analyze borrowing trends and inventory needs.

10
SOURCE CODE

a) For Python
import mysql.connector
from datetime import datetime

# Establishing the connection


conn = mysql.connector.connect(
host="localhost",
user="your username/ root",
password="your_password",
database="library_db")

cursor = conn.cursor()

def add_book(title, author):


cursor.execute("INSERT INTO books (title, author) VALUES
(%s, %s)",(title, author))
print("Book added successfully.")
conn.commit()

def view_books():
cursor.execute( "SELECT * FROM books")
books = cursor.fetchall()
for book in books:
print(book)

def add_member(name):
cursor.execute("INSERT INTO members (name) VALUES (%s)",
(name,))
print("Member added successfully.")
conn.commit()

def borrow_book(book_id, member_id):


# Check if the book is available
cursor.execute("SELECT available FROM books WHERE book_id
= %s", (book_id,))
available = cursor.fetchone()[0]
# Update book availability
if available ==1:
cursor.execute("UPDATE books SET available = 0 WHERE book_id
11
= %s", (book_id,))
# Record the transaction
cursor.execute("INSERT INTO transactions (book_id, member_id,
borrow_date) VALUES (%s, %s, %s)", (book_id, member_id,
datetime.now().date()))
print("Book borrowed successfully.")
conn.commit()
else:
print("Book is not available.")

def return_book(book_id, member_id):


# Update book availability
cursor.execute("UPDATE books SET available = 1 WHERE book_id
= %s", (book_id,))
# Update the transaction with the return date
cursor.execute("UPDATE transactions SET return_date = %s WHERE
book_id = %s AND member_id = %s",
(datetime.now().date(), book_id, member_id))
conn.commit()
print("Book returned successfully.")
def main():
while True:
print("Library Management System")
print("1. Add Book")
print("2. View Books")
print("3. Add Member")
print("4. Borrow Book")
print("5. Return Book")
print("6. Exit")
choice = input("Enter your choice: ")
try:
if choice == '1':
title = input("Enter book title: ")
author = input("Enter book author: ")
add_book(title, author)
break

elif choice == '2':


view_books()
break

12
elif choice == '3':
name = input("Enter member name: ")
add_member(name)
break

elif choice == '4':


book_id = int(input("Enter book ID: "))
member_id = int(input("Enter member ID: "))
borrow_book(book_id, member_id)
break

elif choice == '5':


book_id = int(input("Enter book ID: "))
member_id = int(input("Enter member ID: "))
return_book(book_id, member_id)
break

elif choice == '6':


print("Exiting the system")
break

else:
print("Invalid choice. Please try again.")
except:
print('Only Integer')

main()

# Close the connection


cursor.close()
conn.close()

13
b) For SQL

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) NOT NULL,
available INT DEFAULT 1
);

CREATE TABLE members


( member_id INT
AUTO_INCREMENTPRIMARY KEY,
name VARCHAR(255) NOT NULL
);
CREATE TABLE transactions
( transaction_id Int
AUTO_INCREMENT PRIMARY KEY,
book_id INT(3),
member_id INT(3),
borrow_date DATE,
return_date DATE,
FOREIGN KEY (book_id) REFERENCES books(book_id),
FOREIGN KEY (member_id) REFERENCES members(member_id)
);

14
OUTPUT

1)Adding a New Book

Library Management System


1.Add Book
2. View Books
3. Add Member
4. Borrow Book
5. Return Book
6. Exit
Enter your choice: 1
Enter book title: Harry Potter and the Chamber of Secrets
Enter book author: J. K. Rowling
Book added successfully.

---------------------------------------------------------------------------------------------

Library Management System


1.Add Book
2.View Books
3.Add Member
4.Borrow Book
5.Return Book
6.Exit
Enter your choice: 1
Enter book title: Game of Thrones, A Dance with Dragons
Enter book author: George R. R. Martin
Book added successfully.

---------------------------------------------------------------------------------------------

15
2)Viewing Available Books

Library Management System


1.Add Book
2. View Books
3. Add Member
4. Borrow Book
5. Return Book
6. Exit
Enter your choice: 2
(1, 'Harry potter and The Chamber of Secrets', 'J K Rowling', 1)
(2, 'Game of Thrones, A Dance with Dragons', 'George R. R. Martin', 1)

3) Adding a New Member


LibraryManagementSystem
1.Add Book
2. View Books
3. Add Member
4. Borrow Book
5. Return Book
6. Exit
Enter your choice: 3
Enter member name: Robert
Member added successfully.

---------------------------------------------------------------------------------------------

16
4)Borrowing a Book
Library Management System
1.Add Book
2. View Books
3. Add Member
4. Borrow Book
5. Return Book
6. Exit
Enter your choice: 4
Enter book ID: 1
Enter member ID: 1
Book borrowed successfully.

------------------------------------------------------------------------------------------

Checking availability:

Library Management System


1.Add Book
2. View Books
3. Add Member
4. Borrow Book
5. Return Book
6. Exit
Enter your choice: 2
(1, 'Harry potter and The Chamber of Secrets', 'J K Rowling',0 )
(2, 'Game of Thrones, A Dance with Dragons', 'George R. R. Martin', 1)

17
If the book is not available:

Library Management System


1.Add Book
2. View Books
3. Add Member
4. Borrow Book
5. Return Book
6. Exit
Enter your choice: 4
Enter book ID: 1
Enter member ID: 1
Book is not available

---------------------------------------------------------------------------------------------

18
5)Returning a Book
Library Management System
1. Add Book
2. View Books
3. Add Member
4. Borrow Book
5. Return Book
6. Exit
Enter your choice: 5
Enter book ID: 1
Enter member ID: 1
Book returned successfully.

Checking availability:

Library Management System


1.Add Book
2. View Books
3. Add Member
4. Borrow Book
5. Return Book
6. Exit
Enter your choice: 2
(1, 'Harry potter and The Chamber of Secrets', 'J K Rowling', 1)
(2, 'Game of Thrones, A Dance with Dragons', 'George R. R. Martin', 1)

1
6)Exiting

Library Management System


1.Add Book
2. View Books
3. Add Member
4. Borrow Book
5. Return Book
6. Exit
Enter your choice: 6
Exiting the system

7).Some Error management


Library Management System
1. Add Book
2. View Books
3. Add Member
4. Borrow Book
5. Return Book
6. Exit
Enter your choice: 10
Invalid choice. Please try again.
---------------------------------------------------------------------------------------------

Library Management System


1.Add Book
2. View Books
3. Add Member
4. Borrow Book
5. Return Book
6. Exit
Enter your choice:4
Enter book ID: one
Enter member ID: two
Only integer!
---------------------------------------------------------------------------------------------

20
CONCLUSION

The Library Management System developed in this project provides a


practical solution for managing library resources effectively. By
automating routine tasks such as book tracking and member
management, the system reduces manual errors and enhances
efficiency. Future improvements could include adding more features
such as an online catalog, reservation system, and more advanced
reporting tools.

2
BIBLIOGRAPHY

 www.geeksforgeeks.org

 www.stackoverflow.com

 https://www.britannica.com

 Computer Science Book by Sumita Arora

 Computer Science Book by Swati Chawla

22

You might also like