You are on page 1of 27

PM SHRI KENDRIYA VIDYALAYA NO 1 KANCHRAPARA

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

I wish to express my deep gratitude and sincere thanks to the


Principal, MR. P. DESHMUKH and for his encouragement and for the
facilities that they have provided for this project work.
I extend my heartly thanks to MR. ARKOPAL ROY teacher of
Computer Science who guided us to the successful completion of this project.
I take this opportunity to express my deep sense of gratitude for their
invaluable guidance and immense motivation which has sustained my efforts at
all stages of this project work.

I cannot forget to offer my sincere thanks to my fellow classmates


who helped me carry out this project work successfully and for their
valuable advice and support.

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

One of my friend’s is a library attendee of a library which provides all

kinds of interesting books for many bibliophiles. I have visited his

library office previous week. I saw they are managing work manually.

Customers are waiting until the book entries done in the system. To

start a online management system to handle the entries, it would probably

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.

This motivates us to make a software for them. So, I have collected

the required information and started working on it.

Aim: Developing a software for library and patrons, to maintain the records

easily

Title: LIBRARY MANAGEMENT SYSTEM

Problem Definition:
Develop a software named LIBRARY
Management System to manage the entries and records of
books.
INTRODUCTION

This program helps a library named Indian library which

provides a large collection of books.

This project has 2 main modules presented by menus. These


modules are:
1. Register and login.
2. Book management
Input /Output Requirements

Data for any system is like food for us. Data needs to be

fed by user in the system to work with a specific software.

After processing the data final result will be printed as

output.

So as per this project is concern the input enter by user is as


follows:

1. Login: Users can register with the username and password


of their local account and login also.

2.Management: Users can make number of records as they


want. It includes adding a book under which they have to
give details of name of book, author name and ISBN
number. They can also update, search and delete their
records.
Hardware and Software Requirements

 Hardware Requirements

Processor : Intel Core i3 or higher

Hard Disk (Space) : 100 MB (Minimum)

1 GB (Recommended)

Ram : 1 GB

Keyboard : Any keyboard (QWERTY)

Mouse : Any standard mouse

Monitor : Any monitor with standard resolution

 Software Requirements

Operating System : Windows 7 or higher (64-Bit)

Platform : Python 3.9 or cmd

Database : MySQL SERVER 8.0 or higher

Languages : Python, SQL

Text Editor : Notepad


FLOW CHART

add book details

view all books

update a book

LIBRARY
management register or login delete a book
system

delete all books

search for book

logout
System Design

System design refers to the interface of a software which satisfies the

need for the end-user requirements. System design should be

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

Connected to the database.


-------LIBRARY MANAGEMENT SYSTEM---------
1. Register
2. Login
3. Exit
Enter your choice (1-3): 1
Enter your username: root
Enter your password: 12345678
Registration successful.
LOGIN 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: ")

# Check if the username and password match


cursor.execute('SELECT * FROM users WHERE username=%s AND
password=%s', (username, password))
user = cursor.fetchone()
if user:
print(f"Login successful. Welcome, {username}!")
return True
else:
print("Invalid username or password. Please try again.")
return False

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: "))

cursor.execute('''INSERT INTO books (title, author, price,


quantity)values (%s, %s, %s, %s), (title, author, price,
quantity)’’’)
conn.commit()
print("Book added successfully.")

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.")

# Main login loop


while True:
print("\n1. Register\n2. Login")
login_choice = input("Enter your choice (1 or 2): ")
if login_choice == '1':
register_user()
elif login_choice == '2':
if login_user():
break # Exit the login loop if login is successful
else:
if login_choice >= '2’:
print("Invalid choice. Please enter a number between 1 and 2.")
# Main program loop (after successful login)
while True:
print("\n1. Add a book\n2. View all books\n3. Update a book\n4. Delete a book\

n5. Delete all books\n6. Search for books\n7. Logout")


choice = input("Enter your choice (1-7): ")
if choice == '1':
add_book()
elif choice == '2':
view_books()
elif choice == '3':
update_book()
elif choice == '4':
delete_book()
elif choice == '5':
delete_all_books() # New option to delete all books
elif choice == '6':
search_books()
elif choice == '7':
break
# Logout and exit the program
else:
print("Invalid choice. Please enter a number between 1 and
7.")
# Remember to close the connection when you're done
conn.close()
Database Dictionary

Database dictionary plays an important role in project. It

saves the output generated by python program. We have

used MySQL in the back end to store data. We have used

following tables to manage this project data efficiently.

Just have a look at these tables:

i)Users: Users table consists of data regarding users login

information such as username and password.

The structure of users table is as follows:

Field Type Null Key Default Extra


Id int NO PRI NULL auto_increment
Username varchar(25) YES NULL
Password varchar(25) YES NULL

ii)Books: A books table is created and it contains the

details of id, book title, author’s name, price and quantity.

Field
f Type Null Key Default Extra

id int NO PRI NULL | auto_increment


title varchar(25) YES NULL
author varchar(25) YES NULL
price float YES NULL
quantity int YES NULL
SQL CODE FOR TABLE USERS:

CREATE TABLE IF NOT EXISTS users (


id INTEGER PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(25) UNIQUE,
password VARCHAR(25));

SQL CODE FOR TABLE BOOKS:

CREATE TABLE IF NOT EXISTS books (


id INTEGER PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(25),
author VARCHAR(25),
price FLOAT,
quantity INTEGER);
SOME SQL FUNCTIONS USED IN THE
PROGRAM:

1. cursor.execute( )
2. existing_user = cursor.fetchone()
3. conn.commit()
4. books = cursor.fetchall()
5. conn.close()
CONCLUSION

Making project like this is a great journey of learning. We

learn so many things while developing this project. As we

have started, we learnt how organization functions and

collect data.

With reference to technical knowledge, it was also a great

experience with learning as well, whether it is python or

My SQL or putting logics into code.

This is not the end but we have started a journey with this

project and hope many more to come in future. In addition

to this, constant update for this project will be provided as

per the requirements of the library and e-platforms.


Bibliography

 Computer Science with Python Textbook for Class XII

By Sumita Arora

 Computer Science Text Book for Class XII By NCERT

 www.tutorialaicsip.com

 www.youtube.com

 www.geekforgeeks.com

 www.stackoverflow.com

 www.tutorialpoints.com

You might also like