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

class 12 computer science project

csv library

Uploaded by

mizat
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)
86 views

class 12 computer science project

csv library

Uploaded by

mizat
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/ 33

LIBRARY DATABASE MANAGEMENT

By Sampreethe.S, Mehanethra

XII-B
INDEX

S.NO TOPIC PAGE NO

1 INTRODUCTION 1

2 HARDWARE AND SOFTWARE 4


REQUIRMENTS

3 WHY PYTHON AND CSV 5

4 DESIGN WORK 6

5 CSV AND PYTHON FILES USED 8

6 MODULES AND FUNCTIONS USED 9

7 CODE 10

8 OUTPUT 19

9 ADVANTAGES 27

10 FURTHER DEVELOPMENT 29

11 BIBLIOGRAPHY 31
INTRODUCTION

Libraries are organized collections of information resources and services that


provide access to a wide range of materials, including books, periodicals,
multimedia, and digital content. They serve as community hubs, offering a space
for research, study, and collaboration.

The organization of libraries encompasses a systematic approach to managing


collections and services, particularly regarding the lending and returning of
materials. Libraries typically categorize their collections into sections, such as
fiction, non-fiction, using classification systems for easy navigation. Each item is
assigned a specific call number, which helps people in locating resources. The
lending process is streamlined through well-defined check-out and return
procedures, often facilitated by automated systems that track item status and user
accounts.

Libraries need a database system to help manage and organize their wide range of
materials, including books, journals, and digital content. A good database makes it
easy to find what patrons are looking for quickly and keeps everything well-
cataloged. It also simplifies important tasks like tracking loans, making operations
run more smoothly. Additionally, a database allows for advanced search options,
helping users discover resources more easily.

This project is a Python program that uses CSV (comma separated values) to create
a database to store details of the books in the library, helping librarians and the
public to easily enter, update, delete and view the details of the books, while also
being able to check whether or whether not a specific book has been loaned or not.
The system offers an intuitive user interface, making it easily accessible for non-
technical users and helps maintain efficiency which is important in a library.

1
OBJECTIVE:

The objective of a library database that allows users to create, delete, update, and
view details of books, as well as track who has borrowed specific titles, is to
enhance both resource management and user interaction. This system enables
librarians to efficiently add new books, remove outdated or damaged ones, and
update information like availability or catalog details.

Additionally, by capturing and displaying borrowing records, the database helps


track which patrons have borrowed specific books, facilitating smooth circulation
management. This functionality not only promotes better organization but also
improves accountability and user experience, ensuring that both librarians and
patrons can easily access and manage the library’s resources.

MAIN FUNCTIONS:

1. Creating Book Entries: Users can easily add new books to the inventory by
giving needed information, such as title, serial no., author, genre, etc. This
function allows the details of new books to be added easily so that the
information can later be used/viewed.
2. Lending Books: This function can be used to lend books to the borrowers
and log in the details of which book is with whom. This makes it easier to
locate books efficiently without wasting time.
3. Update Book: Sometimes the details of a book might need to be changed or
modified, which is when this function is used. It allows users to modify the
certain records of a book without altering the entire entry. For example if the
price of a book must be changed, this function makes it easier to do that
without having to disturb any other detail.

2
4. Deleting Books: When a book is no longer available in the library, this
function makes it simple to delete the details of it from the database,
maintaining accuracy in the system.
5. Search For Books: This allows users to find and access the details of a
certain book without having to struggle and waste time. This function can
filter out the unnecessary books and show the ones that meet the exact
conditions provided.
6. Returning A Book: After finishing with a book, the borrower may come
back and return it for the use of others. In order to maintain accuracy about
which books have been returned or not, this function is used.

3
HARDWARE AND SOFTWARE REQUIREMENTS

HARDWARE

• Device name: DESKTOP-PUQK5HI


• Processor: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz 2.70
GHz
• Installed RAM: 16.0 GB (15.9 GB usable)
• Device ID: D253DE6F-CE09-4353-A06E-57FB9135F317
• Product ID: 00330-50529-93097-AAOEM
• System type: 64-bit operating system, x64-based processor
• Pen and touch: No pen or touch input is available for this display

SOFTWARE

• Edition: Windows 11 Pro


• Version: 21H2
• Installed on: 4/6/2023
• OS build: 22000.2538
• Experience: Windows Feature Experience Pack 1000.22001.1000.0
• Python version: 3.12.5150.0(64-bit)
• Notepad

4
WHY PYTHON AND CSV ?

Python and CSV are commonly used for library databases due to their simplicity
and versatility. Python, with its user-friendly syntax and robust libraries like
Pandas, allows for easy manipulation of data, making it ideal for tasks such as data
entry, retrieval, and analysis.

CSV (Comma-Separated Values) files provide a straightforward format for storing


data, making it easy to import and export information between different systems.
This combination enables librarians to efficiently manage book records, track
loans, and update user information without complex database systems. Together,
Python and CSV facilitate quick, flexible, and effective data management in
libraries.

Additionally, using Python with CSV files makes it easier for library staff to work
together and share information. By creating simple scripts, librarians can automate
everyday tasks, such as generating reports on book checkouts which saves time and
reduces mistakes. Python can also handle larger collections, making it simple for
libraries to grow as their number of books and users increases. This combination
not only streamlines library operations but also enhances the experience for library
visitors.

5
DESIGN WORK

System Design:

1. User Interface: The system will have a menu-driven interface, allowing


users to interact with the system and perform tasks.

2. Data Storage: The system will store data in a CSV file, which will be used
to store information about books, users, and lending activities.

3. Data Access: The system will use the csv module to access and modify the
data in the CSV file.

4. Error Handling: The system will implement error handling to ensure that
the system can recover from errors and exceptions.

System Flow:

This is a high-level overview of the system design and flow. The specific
implementation details will depend on the requirements of the system and the
needs of the users.

6
• Create a new book: Prompt for
book details, validate input, and
add to CSV file.

• Search for books: Prompt for


search criteria, search CSV file,
Main Menu: Display a main

and display results.

• Update a book: Prompt for book


menu with options

title, search CSV file, prompt for


updated details, and update CSV
file.

• Delete a book: Prompt for book


title, search CSV file, prompt for
Performs actions
confirmation, and delete from CSV
file.

• Lend a book: Prompt for book


title, search CSV file, prompt for
borrower's details, and update
CSV file.

• Return a book: Prompt for book


title, search CSV file, prompt for
confirmation, and update CSV file.

Exit: If the user selects "Exit",


display a farewell message and
terminate the program

7
CSV AND PYTHON FILES USED

CSV FILE:

library_management.csv

8
MODULES AND FUNCTIONS USED

MODULES:

csv: This module is used to read and write data to the CSV file.

FUNCTIONS:

• create_book(): Creates a new book entry in the CSV file.


• lend_book(): Lends a book to a user.
• search_book(): Searches for books by name, author, or genre.
• update_book(): Updates a book entry in the CSV file.
• delete_book(): Deletes a book entry from the CSV file.
• return_book(): Returns a lent book.
• main(): The main function that runs the Library Management System.

CSV MODULE FUNCTIONS:


• csv.writer(): Creates a CSV writer object.
• csv.reader(): Creates a CSV reader object.
• writerow(): Writes a single row to the CSV file.
• writerows(): Writes multiple rows to the CSV file.
• next(): Returns the next row from the CSV reader object.

9
CODE

import csv

# Define the field names

FIELD_NAMES = ['book_name', 'serial_number', 'isbn_number', 'author_name',


'lent_or_not', 'lenders_name', 'price', 'genre', 'quantity']

# Define the CSV file name

CSV_FILE = 'library_management.csv'

def create_book():

"""Create a new book entry"""

book_data = {}

for field in FIELD_NAMES:

if field == 'lent_or_not':

book_data[field] = 'No'

elif field == 'lenders_name':

book_data[field] = ''

else:

book_data[field] = input("Enter " + field + ": ")

10
with open(CSV_FILE, 'a', newline='') as f:

cw = csv.writer(f)

cw.writerow([book_data[field] for field in FIELD_NAMES])

print("Book created successfully!")

def lend_book():

"""Lend a book"""

book_name = input("Enter book name: ")

with open(CSV_FILE, 'r', newline='') as f:

creader = csv.reader(f)

rows = list(creader)

for i in range(len(rows)):

if rows[i][0] == book_name:

print("Book found!")

if rows[i][4] == 'No':

lenders_name = input("Enter lenders name: ")

rows[i][4] = 'Yes'

rows[i][5] = lenders_name

print("Book lent successfully !")

else:

11
print("Book is already lent!")

break

else:

print("Book not found!")

with open(CSV_FILE, 'w', newline='') as f:

cw = csv.writer(f)

cw.writerows(rows)

def search_book():

"""Search for books by name, author, or genre"""

book_name = input("Enter book name (optional): ")

author_name = input("Enter author name (optional): ")

genre = input("Enter genre (optional): ")

with open(CSV_FILE, 'r', newline='') as f:

creader = csv.reader(f)

books = []

for row in creader:

if (book_name and row[0].lower() == book_name.lower()) or not


book_name:

if (author_name and row[3].lower() == author_name.lower()) or not


author_name:
12
if (genre and row[7].lower() == genre.lower()) or not genre:

books.append(row)

if books:

print("Books found:")

for book in books:

print("Book Name: " + book[0])

print("Serial Number: " + book[1])

print("ISBN Number: " + book[2])

print("Author Name: " + book[3])

print("Lent or Not: " + book[4])

print("Lenders Name: " + book[5])

print("Price: " + book[6])

print("Genre: " + book[7])

print("Quantity: " + book[8])

print("---")

else:

print("No books found!")

def update_book():

"""Update a book entry"""

13
book_name = input("Enter book name: ")

with open(CSV_FILE, 'r', newline='') as f:

creader = csv.reader(f)

rows = list(creader)

for i in range(len(rows)):

if rows[i][0] == book_name:

print("Book found!")

print("Current details:")

for j in range(len(FIELD_NAMES)):

print(FIELD_NAMES[j] + ": " + rows[i][j])

field_name = input("Enter field name to update: ")

field_index = FIELD_NAMES.index(field_name)

if field_name == 'lent_or_not':

new_value = input("Enter new value for " + field_name + " (Yes/No): ")

elif field_name == 'lenders_name':

new_value = input("Enter new value for " + field_name + ": ")

else:

new_value = input("Enter new value for " + field_name + ": ")

rows[i][field_index] = new_value

print("Book updated successfully!")

14
break

else:

print("Book not found!")

with open(CSV_FILE, 'w', newline='') as f:

cw = csv.writer(f)

cw.writerows(rows)

def delete_book():

"""Delete a book entry"""

book_name = input("Enter book name: ")

with open(CSV_FILE, 'r', newline='') as f:

creader = csv.reader(f)

rows = list(creader)

for i in range(len(rows)):

if rows[i][0] == book_name:

print("Book found!")

del rows[i]

print("Book deleted successfully!")

break

else:

15
print("Book not found!")

with open(CSV_FILE, 'w', newline='') as f:

cw = csv.writer(f)

cw.writerows(rows)

def return_book():

"""Return a book"""

book_name = input("Enter book name: ")

with open(CSV_FILE, 'r', newline='') as f:

creader = csv.reader(f)

rows = list(creader)

for i in range(len(rows)):

if rows[i][0] == book_name:

print("Book found!")

if rows[i][4] == 'Yes':

rows[i][4] = 'No'

rows[i][5] = ''

print("Book returned successfully!")

else:

16
print("Book is not lent!")

break

else:

print("Book not found!")

with open(CSV_FILE, 'w', newline='') as f:

cw = csv.writer(f)

cw.writerows(rows)

def main():

while True:

print("Library Management System")

print("1. Create a new book")

print("2. Lend a book")

print("3. Update a book")

print("4. Delete a book")

print("5. Search for books")

print("6. Return a book")

print("7. Exit")

choice = input("Enter your choice: ")

if choice == '1':

17
create_book()

elif choice == '2':

lend_book()

elif choice == '3':

update_book()

elif choice == '4':

delete_book()

elif choice == '5':

search_book()

elif choice == '6':

return_book()

elif choice == '7':

break

else:

print("Invalid choice!")

main()

18
OUTPUT

CREATE NEW BOOK:

19
RESULT:

20
SEARCH FOR BOOKS:

21
UPDATE BOOK:

RESULT:

22
DELETE BOOKS:

RESULT:

23
LEND BOOKS:

RESULT:

24
RETURN BOOKS:

25
EXIT:

26
ADVANTAGES

• Easy to Use: The code provides a simple and intuitive interface for users to
interact with the library database. It offers a menu-driven system that allows
users to perform various operations such as creating a new book, lending a
book, searching for books, updating a book, deleting a book, and returning a
book.

• Data Persistence: The code uses a CSV file to store the library data, which
means that the data is persisted even after the program is closed. This
ensures that the library data is safe and can be retrieved later.

• Data Validation: The code performs basic data validation to ensure that the
user input is correct. For example, it checks if the book name already exists
before creating a new book.

• Search Functionality: The code provides a search functionality that allows


users to search for books by name, author, or genre. This makes it easy for
users to find specific books in the library.

• Lending and Returning Books: The code allows users to lend and return
books, which is a critical feature for a library management system. It keeps
track of which books are lent and to whom, making it easy to manage the
library's inventory.

27
• Updating and Deleting Books: The code allows users to update and delete
book records, which is useful for maintaining the accuracy and integrity of
the library's data.

• Platform Independence: The code is written in Python, which is a


platform-independent language. This means that the code can run on any
platform that has a Python interpreter, including Windows, macOS, and
Linux.
• Easy to Maintain: The code is well-structured and easy to understand,
making it easy to maintain and modify. It uses clear and concise variable
names, and each function has a single responsibility, making it easy to debug
and test.

• Scalability: The code uses a CSV file to store the library data, which means
that it can handle a large number of books without significant performance
degradation. However, for very large libraries, a more robust database
solution may be necessary.

• Security: The code does not have any built-in security features, but it can be
modified to include authentication and authorization mechanisms to ensure
that only authorized users can access and modify the library data.

28
FURTHER DEVELOPMENT

1. User Authentication and Authorization: Implement a user authentication


system to ensure that only authorized users can access and modify the library data.
This can be done using a username and password system, or even integrate with
existing authentication systems like LDAP or Active Directory.

2. Book Reservation System: Add a feature to allow users to reserve books that
are currently lent out. This can be done by adding a "reserved" field to the book
record and allowing users to reserve a book if it's currently lent out.

3. Book Recommendation System: Implement a book recommendation system


that suggests books to users based on their reading history and preferences. This
can be done using machine learning algorithms and natural language processing
techniques.

4. Book Reviews and Ratings: Allow users to leave reviews and ratings for books
they've read. This can help other users make informed decisions about which books
to read.

5. Book Availability Alerts: Implement a system that sends alerts to users when a
book they've reserved becomes available.

6. Library Branch Management: Add support for multiple library branches, each
with their own inventory of books. This can be done by adding a "branch" field to
the book record, and allowing users to search for books by branch.

7. Book Import and Export: Add features to import and export book data from
other sources, such as online bookstores or other library systems.

29
8. Reporting and Analytics: Implement a reporting system that provides insights
into library usage, such as most popular books, most active users, and book
circulation statistics.

9. Integration with Online Catalogs: Integrate the library database with online
catalogs like Goodreads or LibraryThing, allowing users to access more
information about books and authors.

10. Mobile App Development: Develop a mobile app that allows users to access
the library database and perform operations like searching for books, reserving
books, and checking out books.

11. Barcode Scanning: Implement a barcode scanning system that allows


librarians to quickly check out and check in books using a barcode scanner.

12. Automated Reminders: Implement a system that sends automated reminders


to users when their books are overdue or when they have reserved books that are
available.

13. Book Cover Images: Add support for storing book cover images, allowing
users to view the cover art for each book.

30
BIBLIOGRAPHY:

1. BOOKS:
• COMPUTER SCIENCE with python book for class XII by Sumita Arora
• COMPUTER SCIENCE with python book for class XI by Sumita Arora
2. WEBSITES:
• Geek for geeks
• W3Schools
3. YOUTUBE:
• freeCodeCamp

31

You might also like