0% found this document useful (0 votes)
16 views24 pages

CS PROJECT

The document outlines a Computer Science project titled 'Library Management System' completed by a student named Vanshika from St. John's Public School. It includes sections such as a certificate of completion, acknowledgements, an introduction to the system, features, database structure, source code, output, and bibliography. The project aims to streamline library management by providing a user-friendly software solution to replace manual systems.

Uploaded by

born.to.slay56
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)
16 views24 pages

CS PROJECT

The document outlines a Computer Science project titled 'Library Management System' completed by a student named Vanshika from St. John's Public School. It includes sections such as a certificate of completion, acknowledgements, an introduction to the system, features, database structure, source code, output, and bibliography. The project aims to streamline library management by providing a user-friendly software solution to replace manual systems.

Uploaded by

born.to.slay56
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/ 24

ST.

JOHN’S PUBLIC
SCHOOL
Computer Science Project
LIBRARY MANAGEMENT SYSTEM

NAME : VANSHIKA
CLASS : XII
SECTION : A
ROLL NO. :
SUBJECT : Computer Science
SUBMITTED TO : Mr. Jwala Prasad
INDEX

S.NO CONTENT PAGE


NO.
01. Certificate 3
02. Acknowledgement 4
03. Introduction 5
04. Featured provided by 7
the program
05. Database & Tables 8
06. Source code 12
07. Output 22
08. Bibliography 26
CERTIFICATE
This is to certify that Vanshika ofGrade
XII ‘A’, St.John’s Public School,Delhi has
completed the project titled ‘Library
Management System’ during the academic year
2024-25 towards partial fulfillment of the
computer science practical examination
conducted by CBSE, New Delhi & submitted
satisfactory report as compiled in the following
pages, under my supervision.

Mr. Jwala Prasad Sr. Catherine


Class Teacher Principal

External
ACKNOWLEDGEMENT

I would like to express my special thanks of


gratitude to my teacher Mr. Jwala Prasad who
gave me the excellent opportunity to do this
wonderful project on the topic ‘Library
Management System’, which also helped me in
doing a lot of Research and I came to know about
so many new things.
Secondly, I would also like to thank my parents
and friends who helped me a lot in finalizing this
project within the limited time frame.
INTRODUCTION

The "Library Management System" has


been developed to override the problems
prevailing in the practicing manual
system. This software is supported to
eliminate and, in some cases, reduce the
hardships faced by this existing system.
The application is reduced as much as
possible to avoid errors while entering
the data. No formal knowledge is needed
for the user to use this system. Thus, by
this all it proves it is user-friendly.
Library Management System, as
described above, can lead to error free,
secure, reliable and fast management
system. It can assist the user to
concentrate on their other activities
rather to concentrate on the record
keeping. Thus, it will help organization in
better utilization of resources.
FEATURES PROVIDED BY
THE PROGRAM:

• Easy way to enter new books.


• Keep record of complete information of books like;
Book name, Author Name
• Easy way to make a check-out
• Easy to enter new record
• Easy way to modify or delete a book record
• And much more
DATABASE and TABLE
description

Creating database: LibraryDB

Create table: books


Create tables: MEMBERS and
issuedbooks

TABLE: Books
TABLE: MEMBERS
TABLE: issuedbooks
SOURCE CODE
import mysql.connector

print("##############################################")
print("# #")
print("# WELCOME TO LIBRARY MANAGEMENT SYSTEM #")
print("# #")
print("##############################################")

def connect_to_db():

conn= mysql.connector.connect(

host="localhost",

user="root", # MySQL default username is ‘root’

password="root", # MySQL password

database="LibraryDB" # database name

return conn

connect_to_db()
def test_connection():

conn= connect_to_db()
cursor= conn.cursor()#pointer that allows to execute sql queries
and fetch data from database

cursor.execute("Select * from books")


for row in cursor.fetchall(): #fetches all rows returned by the
query

print(row)
conn.close()
test_connection()
print(" ")
print("~~~~~~~~~~~~~Add Books~~~~~~~~~~~~")
print(" ")

#add book function

def add_books():

conn = connect_to_db()

cursor = conn.cursor()

while True:
title = input("Enter book title: ")
author = input("Enter author: ")
quantity = int(input("Enter quantity: "))

query = "INSERT INTO Books (title, author, quantity) VALUES


(%s, %s, %s)"
cursor.execute(query, (title, author, quantity))

conn.commit()
print("Book added successfully!")
print(" ")
print("`````^.^````^.^````^.^``````")
print(" ")
# Ask if the user wants to add more books
more_books = input("Do you want to add another book? (yes/no):
")
if more_books.lower() != 'yes':
break

conn.close()
add_books()

print(" ")

print("~~~~~~~~~~~~~Search Book~~~~~~~~~~~~~")

print(" ")

#search book function

def search_book():

conn=connect_to_db() # Connect to the database

cursor=conn.cursor() # Create a cursor to execute SQL queries

while True:
title = input("Enter book title to search (or type 'exit' to
stop): ")
if title.lower() == 'exit':
break

# Execute the query to search for books by title


query = "select * from books where title like %s"
cursor.execute(query, ('%' + title + '%',))

# Fetch the results and display them


books = cursor.fetchall()
if books:
for book in books:
print(f"ID: {book[0]}, Title: {book[1]}, Author:
{book[2]}, Quantity: {book[3]}")
else:
print("No books found with that title.")

conn.close()

search_book()

print(" ")

print("~~~~~~~~~~~~~Issue Book~~~~~~~~~~~~~")
print(" ")

print("Total Books in the Library:")

def Total_Books():

conn= connect_to_db()

cursor= conn.cursor()#pointer that allows to execute sql queries


and fetch data from database

cursor.execute("Select * from books")

for row in cursor.fetchall(): #fetches all rows returned by the


query
print(row)
conn.close()

Total_Books()

#issue book function

def issue_book():

try:

conn = connect_to_db()

cursor = conn.cursor()

book_id = int(input("Enter book ID: ")) # Ensure this is an


integer.

# Check if the book exists


cursor.execute("SELECT * FROM Books WHERE book_id = %s",
(book_id,))
book = cursor.fetchone()#fetches just one row at one time

if not book:
print("No such book found!")
return #stops further execution
# Check if there are available copies of the book
if book[3] <= 0: # Assuming book[3] is the quantity
print("Sorry, no copies of this book are available for
issuing.")
return
issue_date = input("Enter issue date (YYYY-MM-DD): ")

# Insert the issued book record into IssuedBooks


query = "INSERT INTO IssuedBooks (book_id, issue_date) VALUES
(%s, %s)"
cursor.execute(query, (book_id, issue_date))

# Update book quantity in the Books table


query_update = "UPDATE Books SET quantity = quantity - 1 WHERE
book_id = %s"
cursor.execute(query_update, (book_id,))

conn.commit()
print("Book issued successfully!")
except mysql.connector.Error as err:
print(f"Error: {err}")
finally:
conn.close()
issue_book()

#return book function

print(" ")

print("~~~~~~~~~~~~~return Book~~~~~~~~~~~~~")

print(" ")

def return_book():

conn = connect_to_db()

cursor = conn.cursor()

issue_id = int(input("Enter issue ID: "))


return_date = input("Enter return date (YYYY-MM-DD): ")
query = "UPDATE IssuedBooks SET return_date = %s WHERE issue_id
= %s"
cursor.execute(query, (return_date, issue_id))

query_update = "UPDATE Books SET quantity = quantity + 1 WHERE


book_id = (SELECT book_id FROM IssuedBooks WHERE issue_id = %s)"
cursor.execute(query_update, (issue_id,))

conn.commit()
print("Book returned successfully!")
conn.close()

return_book()

print(" ")

print("`````^.^^.^^.^``````")

print(" ")

#delete book function

print(" ")

print("~~~~~~~~~~~~~delete Book~~~~~~~~~~~~~")

print(" ")

def delete_book():

conn = connect_to_db()

cursor = conn.cursor()

while True:
book_id = int(input("Enter book ID to delete (or type '0' to
stop): "))
if book_id == 0:
break

# Check if the book exists


cursor.execute("SELECT * FROM Books WHERE book_id = %s",
(book_id,))
book = cursor.fetchone()

if not book:
print("No such book found!")
else: #confirm the deletion
confirm = input(f"Are you sure you want to delete the book
'{book[1]}'? (yes/no): ")
if confirm.lower() == 'yes':

cursor.execute("DELETE FROM IssuedBooks WHERE book_id = %s",


(book_id,))

conn.commit()

cursor.execute("DELETE FROM Books WHERE book_id = %s",


(book_id,))
conn.commit()
print("Book deleted successfully!")
else:
print("Deletion cancelled.")

conn.close()
delete_book()

print(" ")

print("`````^.^^.^^.^``````")

print(" ")

#main menu

def main_menu():

while True:

print("\nLibrary Management System")

print("1. Add Book(s)")


print("2. Search Book")

print("3. Issue Book")

print("4. Return Book")

print("5. Delete Book")

print("6. Exit")

choice = int(input("Enter your choice (only numbers): "))

if choice == 1:
add_books() # Updated function to add multiple books
elif choice == 2:
search_book()
elif choice == 3:
issue_book()
elif choice == 4:
return_book()

elif choice == 5:
delete_book()
elif choice == 6:
print("Exiting the program. ")
break
else:
print("Invalid choice!")

main_menu()

print(" ")

print("~~~~~~^.^~~~~^.^~~THANK YOU ~~~~~~^.^~~~~~~~^.^~~~~~~~~")

print(" ")
OUTPUT
BIBLIOGRAPHY
• www.google.com
• www.mysql.com
• www.python.org

You might also like