0% found this document useful (0 votes)
6 views27 pages

CS 5 BookStoreManagementSystem

The document outlines a Computer Science project for a BookStore Management System, detailing its objectives, functionalities, and the integration of Python and MySQL. It includes sections on hardware and software requirements, source code, and user/admin panels for managing book inventory and user interactions. Additionally, it provides acknowledgments, a certificate, and references used in the project.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views27 pages

CS 5 BookStoreManagementSystem

The document outlines a Computer Science project for a BookStore Management System, detailing its objectives, functionalities, and the integration of Python and MySQL. It includes sections on hardware and software requirements, source code, and user/admin panels for managing book inventory and user interactions. Additionally, it provides acknowledgments, a certificate, and references used in the project.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Computer Science Project

2024-2025

Project Topic

BookStore MANAGEMENT SYSTEM

Submitted by:
Name:
Class:
Roll Number:
CONTENTS
S.No. TOPIC PAGE NO

1 Certificate 3

2 Acknowledgement 4

3 Hardware’s and 5
Software’s required
4 Introduction 6

5 Python source code 11

6 MySQL Database 18

7 Outputs 20

8 References 27
CERTIFICATE

This is to certify that <<Student Name>> of class: XII of <<School


Name >> has done her project on BookStore MANAGEMENT
SYSTEM under my supervision. He/She has Taken interest and has
shown at most sincerity in completion of this project.
I certify this project up to my expectation & as per guidelines issued by
CBSE, NEW DELHI.

Internal Examiner External Examiner

Principal
ACKNOWLEDGEMENT

It is with pleasure that I acknowledge my sincere gratitude to


our teacher, << Teacher Name >> who taught and undertook the
responsibility of teaching the subject computer science. I have
been greatly benefited from his classes.

I am especially indebted to our principal <<Principal Name >>


who has always been a source of encouragement and support
and without whose inspiration this project would not have been
successful.

Finally, I would like to express my sincere


appreciation for all my batchmates for their help and
suggestions.
Hardware and Software requirements

Hardware:
 Desktop / Laptop

Software:
 PyCharm IDE
 Python
 MySQL
 Python-MySQL connector module
INTRODUCTION

## Objectives of the Project


The primary objective of the BookStore Management
System is to empower bookshop owner with tools that
facilitate efficient inventory management. The system
encompasses key administrative
functionalities, including adding book details, viewing inventory,
updating book details and deleting books from records.

The provided Python script embodies a BookStore


Management System that leverages the capabilities of
MySQL as the backend database.
Functionalities:

#### Admin Panel


The `admin_panel()` function serves as the gateway
to the Admin Panel, offering a menu-driven interface
for administrators to access and utilize the various
functionalities provided by the system.

### Add book to inventory


The `add_book()` function allows administrators to
add book details like name, author name , genre,
available quantities and price to inventory.

### Checking inventory


The `view_books()` function provides
administrators with an interface to check details of all
the books in inventory.
### Updating inventory
The `update_book()` function allows administrator to
update details about book like available quantity,
books genre and book price.

### Deleting books


The `delete_book()` function enables
administrators to remove book records from the
system, providing a mechanism for data cleanup and
management.

#### User Panel


The `user_panel()` function serves as the gateway to
the user Panel, offering a menu-driven interface for
customers to access and utilize the various
functionalities provided by the system.

### User registration


The `user_register()` function allows a customer to
register with the system.
#### User login
The `user_login()` function allows customer to login
to system be verifying user credentials like user name
and password.

#### User logout


The `user_logout()` function allows customer to
logout of the system.

#### Searching books by name


The `search_by_name()` function allows customer to
search the books inventory by book name.

#### Searching books by genre


The `search_by_genre()` function allows customer to
search the books inventory by various genre .
# Integration of MySQL and Python

### MySQL – The Relational Database Management


System
MySQL serves as the backend database for the
Student Management System, storing and managing
student-related information. The structured schema
ensures efficient storage, retrieval, and
manipulation of data.

### Python – The Programming Language


Python, with its versatility and readability, powers the
logic and user interface of the Student Management
System. The script employs Python’s database
connectivity features to seamlessly integrate with
MySQL, providing a cohesive and interactive
experience for users and administrators.
Python source code
import mysql.connector as s
from tabulate import tabulate

DB = s.connect(host="localhost",user="root", password="pwd_pwd",
database="book_store")
C = DB.cursor() # ADMIN FUNCTIONS
logged_in = False

def add_book():
book = input("Enter Book Name: ")
genre = input("Genre:")
quantity = int(input("Enter quantity:"))
author = input("Enter author name:")
price = int(input("Enter the price:"))
C.execute("INSERT INTO available_books values('{}','{}',{},'{}',{})"\
.format(book, genre, quantity, author,price))
DB.commit()
print(" ++++ SUCCESSFULLY ADDED +++++++++++++ ")

def view_books():
C.execute("SELECT * FROM available_books" )
books = C.fetchall()
if books:
columns = []
for i in C.description:
columns.append(i[0])
print(tabulate(books, headers=columns, tablefmt="fancy_grid"))
else:
print("No books present")

def update_book():
name = input("Enter the name of book to be updated:")
C.execute("SELECT * FROM available_books WHERE book ='{}'".format(name))
book = C.fetchone()
if book:
choice = int(input("1 ---> Update genre 2---> Update quantity 3--->Update price 4--
>Exit : "))
if choice == 1:
new_genre = input("Enter new genre : ")
C.execute("UPDATE available_books SET genre = '{}' WHERE
book='{}'".format(new_genre,name))
DB.commit()
print("Successfully updated genre ")
elif choice == 2:
new_quantity = input("Enter new quantity : ")
C.execute("UPDATE available_books SET quantity = {} WHERE
book='{}'".format(new_quantity,name))
DB.commit()
print("Successfully updated quantity ")

elif choice == 3:
new_price = input("Enter new price : ")
C.execute("UPDATE available_books SET price = {} WHERE
book='{}'".format(new_price,name))
DB.commit()
print("Successfully updated price ")
else:
print("Enter a valid choice")
else:
print("No book with this name")

def delete_book():
name = input("Enter the book to be deleted: ")
C.execute("SELECT * FROM available_books WHERE book ='{}'".format(name))
book = C.fetchone()
if book:
C.execute("DELETE FROM available_books WHERE book='{}'".format(name))
DB.commit()
print("Successfully deleted book")
else:
print("No book with this name")

def search_by_name():
book = input("Enter the book name to be searched: ")
C.execute("SELECT * FROM available_books WHERE book ='{}'".format(book))
books = C.fetchall()
if books:
columns = []
for i in C.description:
columns.append(i[0])
print(tabulate(books, headers=columns, tablefmt="fancy_grid"))

else:
print("No book with this name")
def search_by_genre():
genre = input("Enter the genre to be searched: ")
C.execute("SELECT * FROM available_books WHERE genre ='{}'".format(genre))
books = C.fetchall()
if books:
columns = []
for i in C.description:
columns.append(i[0])
print(tabulate(books, headers=columns, tablefmt="fancy_grid"))

else:
print("No book with this genre")

def purchase_book():
book_name = input("Enter the name of the book : ")
C.execute("SELECT * FROM available_books WHERE book ='{}'".format(book_name))
book = C.fetchone()
if book:
quantity = int(input("How many books you want to buy : "))
if book[2] >= quantity:
C.execute("UPDATE available_books SET quantity={}-{} WHERE book
='{}'".format(book[2], quantity, book_name))
DB.commit()
print(" ################# ")
print(" Purchase successful ")
print("Receipt: ")
print("Book purchased :",book_name)
print("Total Bill : ", book[4]*quantity)
print(" ################# ")

else:
print("There are only {} copies of '{}' available".format(book[2],book_name))
else:
print("No book with this name")

def user_register():
while True:
user = input("Enter username: ")
C.execute("SELECT * FROM users WHERE user ='{}'".format(user))
data = C.fetchone()
if data:
print("User already exists. Try different username ")
else:
password = input("Enter password: ")
C.execute("INSERT INTO users VALUES('{}','{}')".format(user,password))
DB.commit()
print("User registered successfully")
break

def user_login():
global logged_in
user = input("Enter username: ")
password = input("Enter password: ")
C.execute("SELECT * FROM users WHERE user='{}'".format(user))
data = C.fetchone()
if data:
C.execute("SELECT password FROM users WHERE user='{}'".format(user))
pwd = C.fetchone()
if pwd[0] == password :
if not logged_in:
logged_in = True
print("Successfully logged in")
else:
print("Already logged in")
else:
print("Username/Password not correct ")
else:
print("Username/Password not correct ")

def user_logout():
global logged_in
logged_in = False
print("Successfully logged out")

def admin_panel():
while True:
print(" ############################# ")
print("Enter 1 for Adding books")
print("Enter 2 for Checking inventory")
print("Enter 3 for Updating inventory")
print("Enter 4 for deleting a book")
print("Enter 5 to exit")
print(" ############################# ")
option = int(input("Enter a option:"))
if option == 1:
add_book()
elif option == 2:
view_books()
elif option == 3:
update_book()
elif option == 4:
delete_book()
elif option == 5:
print("Exiting...")
break
else:
print("Enter a valid option")
return

def user_panel():
while True:
print(" ############################# ")
print("Enter 1 for registering")
print("Enter 2 for login")
print("Enter 3 for searching books by name ")
print("Enter 4 for searching books by genre ")
print("Enter 5 for purchase books")
print("Enter 6 for logout")
print("Enter 7 to exit")
print(" ############################# ")
ch = int(input("Enter user's choice: "))
if ch == 1:
user_register()
elif ch == 2:
user_login()
elif ch == 3:
if logged_in :
search_by_name()
else:
print("Login first")
user_login()
elif ch == 4:
if logged_in :
search_by_genre()
else:
print("Login first")
user_login()
elif ch == 5:
if logged_in:
purchase_book()
else:
print("Login first")
user_login()
elif ch == 6:
if logged_in:
user_logout()
else:
print("You are already logged out")
elif ch == 7:
print("Exiting...")
break
else:
print("Enter a valid option")

while True:
print("Enter 1 for Store Manager")
print("Enter 2 for Customer")
print("Enter 3 for Exit")
choice = int(input("Enter your choice: "))
if choice == 1:
admin_panel()
elif choice == 2:
user_panel()
elif choice == 3:
print("Exiting...")
break
else:
print("Enter a valid option")
Database and Table creation in MySQL

Table available_books
Table users
OUTPUTS
Admin panel:

Adding a book
Checking inventory

Updating price
Deleting a book

User panel
User login
Searching books by name

Searching books by genre


Purchasing book

Final inventory
References :

 Python
https://www.python.org/
 MySQL
https://www.mysql.com/
 Grade 11th and 12th Computer Science
books (Sumita Arora)

You might also like