J.B. Memorial Manas Academy Pithoragarh: Practical File OF Computer Science
J.B. Memorial Manas Academy Pithoragarh: Practical File OF Computer Science
PRACTICAL FILE
OF
COMPUTER SCIENCE
SUBMITTED BY SUBMITTED TO
PIYA RAWAT MR. DEVENDRA
CLASS: 12TH ‘D’ MAHORI
ROLL NO. : ………………………….
1|Page
CONTENTS
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.
4|Page
5|Page
PROJECT ANALYSIS
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
OBJECTIVE
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
12 | P a g e
borrower_name VARCHAR(255)
)
"""
cursor.execute(query)
connection.commit()
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}")
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")
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()
else:
print("\nInvalid choice. Please enter a number between 1 and 6.")
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
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
25 | P a g e