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

J.B. Memorial Manas Academy Pithoragarh: Practical File OF Computer Science

Uploaded by

sharmaji4212
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

J.B. Memorial Manas Academy Pithoragarh: Practical File OF Computer Science

Uploaded by

sharmaji4212
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

J.B.

MEMORIAL MANAS ACADEMY


PITHORAGARH

PRACTICAL FILE
OF
COMPUTER SCIENCE

TOPIC: LIBRARY MANAGEMENT SYSTEM

SUBMITTED BY SUBMITTED TO
PIYA RAWAT MR. DEVENDRA
CLASS: 12TH ‘D’ MAHORI
ROLL NO. : ………………………….

1|Page
CONTENTS

S No. Name Page no.


1. Certificate 3
2. Acknowledgement 4
3. Project analysis 6
4. About python 7
5. About MySQL 8
6. Introduction and objectives 9
7. Python connectivity with SQL 10
8. Coding 12
9. Future scope 23
10. Enhancement and feature ideas 24
11. Bibliography 25

2|Page
J.B. Memorial Manas Academy
Pithoragarh

CERTIFICATE
This is to certify that Piya Rawat of class 12 ‘D'
has successfully completed the project work on
Computer Science on topic Library Management
System for class XII practical examination of the
Central Board of Secondary Education in the year
2023-24. It is further certified that this project is
the individual work ofthe candidate.

Devendra Mahori

3|Page
ACKNOWLEDGMENT
I am immensely grateful to my project guide Mr. Devendra Mahori,
for their invaluable guidance and unwavering support throughout the
duration of this project. Their expertise and mentorship have been
instrumental in shaping the project’s direction and ensuring its
successful completion. I would also like to extend my heartfelt
appreciation to my classmates who collaborated with me on this
project. Their contributions and collective effort have greatly enriched
the outcome.

Additionally, I would like to express my gratitude to the school


administration and faculty for providing us with the necessary
resources and opportunities to undertake this project. Their
encouragement and belief in our abilities have been a constant
source of motivation. Finally, I am indebted to my parents and my
sister for their continuous support and encouragement. Their
unwavering faith in me and their willingness to lend a helping hand
whenever needed have been crucial throughout this journey.

4|Page
5|Page
PROJECT ANALYSIS

T his application program is specially designed for the


school library.
It includes a basic set of all the function required in the
library which are used to reduce the time and increases the
efficiency.
It includes-
• Showing all books present in library
• Lending a book
• Returning a book
• Adding new book to system
I have examined the needs of a library and after the analysis, I
have written the program.

This program uses PYTHON and MYSQL as platform to carry


out the task.

6|Page
ABOUT PYTHON
Python is a high-level, interpreted programming language that
emphasizes readability and simplicity. Developed by Guido van
Rossum and first released in 1991, Python has become one of the
most popular and versatile programming languages. Some key
features include:
• Readability: Python's syntax is designed to be clear and
readable, making it accessible for both beginners and
experienced developers.
• Versatility: Python supports multiple programming paradigms,
including procedural, object-oriented, and functional
programming. This versatility makes it suitable for a wide range
of applications.
• Dynamic Typing: Python is dynamically typed, allowing for
flexibility in variable assignments and function parameters.
• Open source: Python is an open-source language, fostering
collaboration and allowing developers to contribute to its
development.
• Interpreted language: Python is an interpreted language, which
means that code can be executed line by line. This facilitates
quick testing and prototyping.
In summary, Python's simplicity, readability, versatility, and
strong community support contribute to its widespread
adoption for various applications, ranging from web
development and data science to artificial intelligence and
automation.

7|Page
ABOUT MYSQL
MySQL is a widely-used open-source relational database
management system (RDBMS). Developed by Oracle
Corporation, it's known for its reliability, performance, and
ease of use. Key features include:
• Relational Database: MySQL follows a relational database
model, organizing data into tables with predefined relationships.
• Open Source: As an open-source RDBMS, MySQL is freely
available, fostering widespread adoption and community
collaboration .
• Cross-Platform Support: MySQL is compatible with
various operating systems, ensuring versatility across different
environments.
• SQL Language Support: It supports the Structured Query
Language (SQL), providing a standardized means to interact
with Databases.
• Scalability: MySQL caters to both small-scale applications and
large-scale enterprise databases, offering scalability to meet
diverse needs.
In summary, MySQL is a powerful and versatile relational
database management system, widely used for its
performance, reliability, and strong community support

8|Page
INTRODUCTION

The software is used to maintain the records of all


available books, who have taken the books, adding new
books and to search for a book.

OBJECTIVE

The objective of this project is to let students apply the


programming knowledge to the real-world situation and
exposed the students how programming skills helps in
developing a good software.

9|Page
10 | P a g
e
SOURCE
CODE

11 | P a g
e
CONNECTING PYTHON TO SQL
import mysql.connector
# Replace these values with your MySQL server details
host = '127.0.0.1'
user = 'root'
password = 'Sql@369'
database = 'library_app'
port = 3306
try:
# Connect to the MySQL database
conn = mysql.connector.connect(
host=host,
user=user,
password=password,
database=database,
port=port
)
# Check if the connection was successful
if conn.is_connected():
print("Connection to MySQL database established
successfully!")
except mysql.connector.Error as err:
print(f"Error: {err}")
finally:
# Close the connection
if 'conn' in locals() and conn.is_connected():
conn.close()
print("MySQL connection closed.")

10 | P a g e
OUTPUT:

11 | P a g e
SOURCE CODE
import mysql.connector

# MySQL database connectivity details


host = '127.0.0.1'
user = 'root'
password = 'Sql@369'
database = 'library_app'
port = 3306

# Establishing connection to MySQL


connection = mysql.connector.connect(
host=host,
user=user,
password=password,
database=database,
port=port
)

# Creating a cursor object to execute SQL queries


cursor = connection.cursor()

# Function to create the books table if it does not exist


def create_books_table():
query = """
CREATE TABLE IF NOT EXISTS books (
id VARCHAR(4) PRIMARY KEY,
title VARCHAR(255) NOT NULL,
author VARCHAR(255) NOT NULL,
available BOOLEAN NOT NULL,

12 | P a g e
borrower_name VARCHAR(255)
)
"""
cursor.execute(query)
connection.commit()

# Function to add a new book to the library


def add_book(book_id, title, author):
query = "INSERT INTO books (id, title, author, available)
VALUES (%s, %s, %s, %s)"
data = (book_id, title, author, True)
cursor.execute(query, data)
connection.commit()

# Function to lend a book


def lend_book(book_id):
borrower_name = input("Enter your name: ")
query = "UPDATE books SET available = FALSE, borrower_name
= %s WHERE id = %s AND available = TRUE"
data = (borrower_name, book_id)
cursor.execute(query, data)
if cursor.rowcount > 0:
print(f"\nBook with ID {book_id} has been lent to
{borrower_name}.")
connection.commit()
else:
print(f"\nBook with ID {book_id} is not available for lending.")

# Function to return a book


def return_book(book_id):
query = "UPDATE books SET available = TRUE, borrower_name
= NULL WHERE id = %s AND available = FALSE"
13 | P a g e
data = (book_id,)
cursor.execute(query, data)
if cursor.rowcount > 0:
print(f"\nBook with ID {book_id} has been returned.")
connection.commit()
else:
print(f"\nInvalid book ID or book is already available.")

# Function to display all available books in the library


def display_available_books():
query = "SELECT * FROM books WHERE available = TRUE"
cursor.execute(query)
books = cursor.fetchall()

if not books:
print("\nNo books available in the library.")
else:
print("\nAvailable Books:")
for book in books:
print(f"ID: {book[0]}, Title: {book[1]}, Author: {book[2]}")

# Function to search for a book by its name and display its details
def search_book_by_name(book_name):
query = "SELECT * FROM books WHERE title LIKE %s"
data = (f"%{book_name}%",)
cursor.execute(query, data)
books = cursor.fetchall()

if not books:
print(f"\nNo books found with the name '{book_name}'.")
else:
14 | P a g e
print("\nSearch Results:")
for book in books:
availability = "Yes" if book[3] else "No"
borrower_name = book[4] if not book[3] else "N/A"
print(f"ID: {book[0]}, Title: {book[1]}, Author: {book[2]},
Available: {availability}, Borrower: {borrower_name}")

# Creating the books table


create_books_table()

# Attractive welcome message and separator line


print("\n******************************************")
print("******** WELCOME TO THE LIBRARY **********")
print("******************************************")

while True:
print("\nOptions:")
print("1. Add a new book")
print("2. Display available books")
print("3. Lend a book")
print("4. Return a book")
print("5. Search for a book by name")
print("6. Exit")

choice = input("Enter your choice (1-6): ")

if choice == '1':
book_id = input("Enter the 4-digit ID of the book: ")
title = input("Enter the title of the book: ")
author = input("Enter the author of the book: ")
add_book(book_id, title, author)

15 | P a g e
elif choice == '2':
display_available_books()

elif choice == '3':


book_id = input("Enter the ID of the book you want to lend: ")
lend_book(book_id)

elif choice == '4':


book_id = input("Enter the ID of the book you want to return: ")
return_book(book_id)

elif choice == '5':


book_name = input("Enter the name of the book you want to
search: ")
search_book_by_name(book_name)

elif choice == '6':


print("\nThank you for using the library management system.
Exiting the program.")
break

else:
print("\nInvalid choice. Please enter a number between 1 and 6.")

continue_choice = input("\nDo you want to continue? (yes/no): ")


if continue_choice.lower() != 'yes':
print("Thank you for using the library management system.
Exiting the program.")
break

16 | P a g e
# Closing the connection
cursor.close()
connection.close()

OUTPUT WINDOW

17 | P a g e
ADDING NEW BOOK

18 | P a g e
DISPLAY AVAILABLE BOOKS

19 | P a g e
LEND A BOOK

20 | P a g e
RETURN A BOOK

21 | P a g e
SEARCHING A BOOK

22 | P a g e
FUTURE SCOPE OF PROJECT

▪ Our project have a large scope in the future as it is easy to use,


understand and modify.
▪ In the age of evolving technology our software aims to modernize
data.
▪ Our software is a paperless software which make it easy to sustain
and aids the environment.
▪ Our software increases the precision and efficiency by
eliminating the chance of any human error
▪ Our software is laidback and can be accessed by management and
students/ readers.
▪ Our software helps the librarian and library department to access
and maintain the record easily and efficiently of every reader and
it can also be used by readers directly to get the book easily and
fastly.

23 | P a g e
ENHANCEMENT AND FEATURE IDEAS
o User Authentication: Implement a user authentication system to
distinguish between administrators and regular users. This can
allow administrators to perform additional actions, such as adding
or removing users and modifying book records.
o User role and permission: Introduce user roles with different
levels of permissions. For example, administrators may have full
access, while regular users can only borrow and return books.
o Fine system: Create a fine system for late returns. Implement a
feature to calculate and track fines for books returned after the
due date.
o Book categories and genres: Expand the book model to include
categories or genres. Allow users to search or filter books based
on categories or genres.
o Book review and ratings: Allow users to leave reviews and
ratings for books. Create a system to display average ratings for
each book.
o Reservations: Implement a reservation system, allowing users to
reserve books that are currently on loan. Notify users when the
reserved book becomes available.
o Email notification: Implement an email notification system to
remind users of upcoming due dates, overdue books, or when a
reserved book becomes available.
o Data backup and recovery: Set up regular data backups and
implement a recovery mechanism to ensure data integrity and
availability.
o Security: security is most important ensures that data must be
secure and the software must be safe from the attack of the
hackers.

24 | P a g e
BIBLIOGRAPHY

❖ To develop the project following sources were used:

1. Computer science with Sumita Arora


2. https://www.google.com
3. Sololearn

25 | P a g e

You might also like