CS File
CS File
CS File
COMPUTER SCIENCE
INVESTIGATORY PROJECT
TOPIC – LIBRARY MANAGEMENT
SYSTEM
NAME – AKSHAT SHARMA
CLASS – XII ROLL.NO- 20
SECTION –A SESSION- 2023-24
BOARD ROLL.NO –
CERTIFICATE
This is to certify that this project titled
Library Management system is a bonafide work of
Akshat Sharma of class XII-A, submitted to PM
SHRI KENDRIYA VIDYALAYA, for consideration in
the partial accomplishment of senior school
certificate Examination in computer science(083)
subject.
This original work was carried out by under
him under my supervision in the academic year
2023-24.On the basis of declaration made by him I
recommend the project for evaluation.
ACKNOWLEDGMENT
TABLE OF CONTENTS
S.N Description Page No.
1. Preface
2. Introduction to Project
3. Input /Output Requirement
4. Hardware and Software Requirements
5. Flow Chart
6. Source Code
7. System Design
8. Database Dictionary
9. Conclusion
10. Reference or Bibliography
PREFACE
library office previous week. I saw they are managing work manually.
Customers are waiting until the book entries done in the system. To
take 1 day.
Borrowers and librarians both loses their precious time in the manual
process. Due to manual system, they are not able to complete all the
entries and records in time as it is a tedious job to maintain manually.
Aim: Developing a software for library and patrons, to maintain the records
easily
Problem Definition:
Develop a software named LIBRARY
Management System to manage the entries and records of
books.
INTRODUCTION
Data for any system is like food for us. Data needs to be
output.
Hardware Requirements
1 GB (Recommended)
Ram : 1 GB
Software Requirements
update a book
LIBRARY
management register or login delete a book
system
logout
System Design
interactive and presentable. All the options required for the processing
should be present in system way. Here our system design for this
project is as follows:
REGISTRATION INFO
1. Register
2. Login
3. Exit
Enter your choice (1-3): 2
Enter your username: root
Enter your password: 12345678
Login successful. Welcome back mam, root!
ADD A BOOK
1. Add a book
2. View all books
3. Update a book
4. Delete a book
5. Delete all books
6. Search for books
7. Logout
Enter your choice (1-7): 1
Enter the book ID(ISBN): 1234567891
Enter the title: Geetanjali
Enter the author: Rabindra Nath Tagore
Enter the price: 200
Enter the quantity: 1
Book added successfully.
VIEW BOOKS
1. Add a book
2. View all books
3. Update a book
4. Delete a book
5. Delete all books
6. Search for books
7. Logout
Enter your choice (1-7): 2
(2, 'Geetanjali', 'Rabindra Nath Tagore', 200.0, 1)
DELETE A BOOK
1. Add a book
2. View all books
3. Update a book
4. Delete a book
5. Delete all books
6. Search for books
7. Logout
Enter your choice (1-7): 4
Enter the book ID(ISBN) to delete:
1234567891
Book deleted successfully.
DELETE ALL BOOKS
1. Add a book
2. View all books
3. Update a book
4. Delete a book
5. Delete all books
6. Search for books
7. Logout
Enter your choice (1-7): 5
Are you sure you want to delete all books?
(yes/no): yes
All books deleted successfully.
SEARCH A BOOK
1. Add a book
2. View all books
3. Update a book
4. Delete a book
5. Delete all books
6. Search for books
7. Logout
Enter your choice (1-7): 6
Enter the title or part of the title to search: jungle
book
LOGOUT
1. Add a book
2. View all books
3. Update a book
4. Delete a book
5. Delete all books
6. Search for books
7. Logout
Enter your choice (1-7): 7
logout successful
SOURCECODE
import mysql.connector
#Replace 'your_username', 'your_password', and
'your_database' with your MySQL credentials
conn = mysql.connector.connect( host='localhost',user='root’
password='12345678',database='bookshop')
if conn.is_connected():
print("Connected to the database.")
else:
print("Not connected to the database.")
cursor = conn.cursor()
print("-------BOOK SHOP MANAGEMENT SYSTEM--------")
# Create a table for users
cursor.execute(''' CREATE TABLE IF NOT EXISTS users ( id
INTEGER PRIMARY KEY AUTO_INCREMENT, username
VARCHAR(255) UNIQUE, password VARCHAR(255) )''')
conn.commit()
# Create a table for books
cursor.execute('''CREATE TABLE IF NOT EXISTS books (id
INTEGER PRIMARY KEY AUTO_INCREMENT,title
VARCHAR(255), author VARCHAR(255),price FLOAT, quantity
INTEGER)''')
conn.commit()
def register_user():
username = input("Enter your username: ")
password = input("Enter your password: ")
# Check if the username is already taken
cursor.execute('SELECT * FROM users WHERE username=
%s', (username,))
existing_user = cursor.fetchone()
if existing_user:
print("Username already exists. Please choose another
username.")
else:
# Insert the new user into the database
cursor.execute('INSERT INTO users (username, password) VALUES
(%s, %s)', (username, password))
conn.commit()
print("Registration successful.")
def login_user():
username = input("Enter your username: ")
password = input("Enter your password: ")
def add_book():
book_id = int(input("Enter the book ID(ISBN): "))
title = input("Enter the title: ")
author = input("Enter the author: ")
price = float(input("Enter the price: "))
quantity = int(input("Enter the quantity: "))
def view_books():
cursor.execute(‘select*from books')
books = cursor.fetchall()
for book in books:
print(book)
def update_book():
book_id = int(input("Enter the book ID(ISBN) to update: "))
title = input("Enter the new title: ")
author = input("Enter the new author: ")
price = float(input("Enter the new price: "))
quantity = int(input("Enter the new quantity: "))
cursor.execute('''UPDATE booksSET title=%s, author=%s,
price=%s, quantity=%sWHERE id=%s, (title, author, price,
quantity, book_id)’’’)
conn.commit()
print("Book updated successfully.")
def delete_book():
book_id = int(input("Enter the book ID(ISBN) to delete: "))
cursor.execute('DELETE FROM books WHERE id=%s',
(book_id,))
conn.commit()
print("Book deleted successfully.")
def search_books():
title = input("Enter the title or part of the title to search: ")
cursor.execute('SELECT * FROM books WHERE title LIKE %s',
('%' + title + '%',))
books = cursor.fetchall()
for book in books:
print(book)
def delete_all_books():
confirm = input("Are you sure you want to delete all books?
(yes/no): ").lower()
if confirm == 'yes':
cursor.execute('DELETE FROM books')
conn.commit()
print("All books deleted successfully.")
else:
print("Deletion canceled.")
Field
f Type Null Key Default Extra
1. cursor.execute( )
2. existing_user = cursor.fetchone()
3. conn.commit()
4. books = cursor.fetchall()
5. conn.close()
CONCLUSION
collect data.
This is not the end but we have started a journey with this
By Sumita Arora
www.tutorialaicsip.com
www.youtube.com
www.geekforgeeks.com
www.stackoverflow.com
www.tutorialpoints.com