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

Book Stall

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 views20 pages

Book Stall

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/ 20

BOOKSTORE MANAGEMENT SYSTEM

INDEX

1. Brief Overview of Project

2. Need for Computerisation

3. Software and Hardware requirement

4. Source Code of Project

5. Output Screens

6. Bibliography
BRIEF OVERVIEW OF PROJECT

This is a Python program that creates a simple bookstore management system.


The program allows users to sign up or login, add books to the store, delete
books from the store, search for books by various criteria, view staff details,
record sales, and view the total income after the latest reset. The program uses
MySQL as its database management system.

When the program is run, it first creates a connection to the MySQL server
running on the local machine, using the root user and the password “admin”. It
then creates a database called “store” (if it doesn’t already exist) and uses it. It
creates a table called “signup” with columns for “username” and “password”.
This table is used to store user account information.

The program then enters a loop that presents the user with a choice between
signing up and logging in. If the user chooses to sign up, they are prompted to
enter a username and password, which are then stored in the “signup” table. If
the user chooses to log in, they are prompted to enter a username. If the
username is found in the “signup” table, the program prompts the user to enter
their password. If the password is correct, the user is presented with a menu of
options for managing the bookstore.

The options for managing the bookstore are:

1. Add Books: The user is prompted to enter information about a new book
(name, genre, quantity, author, publication, and price). If the book is
already in the store, the quantity is increased. Otherwise, the book is
added to the “Available_Books” table.
2. Delete Books: The user is shown a list of available books and prompted
to enter information about a book to delete (name, quantity, customer
name, phone number, and price). If the requested quantity of the book is
available, a record of the sale is added to the “Sell_rec” table and the
quantity of the book is decreased. Otherwise, an error message is
displayed.
3. Search Books: The user is prompted to choose a search criterion (name,
genre, or author) and enter a search term. The program searches the
“Available_Books” table for books matching the search criterion and
term and displays the results.
4. Staff Details: The user is shown a list of staff details (name, gender, age,
phone number, and address) stored in the “Staff_details” table.
5. Sell Record: The user is shown a list of records of book sales stored in the
“Sell_rec” table.
6. Available Books: The user is shown a list of available books stored in the
“Available_Books” table.
7. Total Income after the Latest Reset: The user is shown the total income
from book sales since the last reset.
8. Exit: The program exits.

Overall, this program provides a basic framework for managing a small


bookstore. However, it has several limitations and potential issues. For example,
the program does not include any error handling or input validation, which
could lead to incorrect or invalid data being stored in the database. Additionally,
the program does not include any authentication or authorization mechanisms,
so anyone with access to the program can perform any action on the database.
ncorrect or invalid data being stored in the database. Additionally, the program
does not include any authentication or authorization mechanisms, so anyone
with access to the program can perform any action on the database.

NEED OF COMPUTERISATION
A Book store software helps retail Book store businesses have complete control
over business from purchase, inventory management to sales where you can
have a track of every operation

SOFTWARE AND HARDWARE REQUIREMENTS:

Data file handling has been effectively used in the program. The database is a
collection of interrelated data to serve multiple applications. That is database
programs create files of information. So we see that files are worked with most,
inside the program.

DBMS: The software required for the management of data is called as DBMS.
It has3 models:

• Relation model

• Hierarchical model

• Network model

RELATIONAL MODEL: It’s based on the concept on relation. Relation is the


table that consists of rows and columns. The rows of the table are called tuple
and the columns of the table are called attribute. Numbers of rows in the table is
called as cardinality. Number of columns in the table is called as degree.

HIERARCHICAL MODEL: In this type of model, we have multiple records for


each record. A particular record has one parent record. No chide record can
exist without parent record. In this, the records are organized in tree.

NETWORK MODEL: In this, the data is represented by collection of records


and relationship is represented by (ink or association.

CHARACTERISTICS OF DBMS:
• It reduces the redundancy
• Reduction of data in inconsistency
• Data sharing
• Data standardization
DIFFERENT TYPES OF FILES: -BASED ON ACCESS:
• Sequential file
• Serial file
• Random (direct access) file BASED ON STORAGE:-
• Text file
• Binary File

Source codescreening

DBMS: MySQL
Host: local host
User: root
Pass: root
Database: book_shop

Table Structure: (Images Bellow)


SOURCE CODE:
def add_user() :

db = cntr.connect(host = 'localhost' , user = 'root' , passwd =


'root',database='book_shop')

cur = db.cursor()
user = input("Enter the user name : ")

passwd = input("Enter a Password : ")

passwd2 = input("Enter Password to confirm : ")

if passwd == passwd2 :

cur.execute("insert into users values('{}','{}')".format(user,passwd))

print("Created Successfully!!!")

elif passwd != passwd2 :

print("You've entered different passwords")

db.commit()

db.close()

def login():

db = cntr.connect(host = 'localhost' , user = 'root' , passwd =


'root',database='book_shop')

cur = db.cursor()

user = input("Enter the username : ")

pwd = input("Enter the password : ")

cur.execute("Select * from users where (username = '{}' and password =


'{}')".format(user , pwd))

if cur.rowcount>0 :

return True

else:

return False

db.close()
def add_stock() :

db = cntr.connect(host = 'localhost' , user = 'root' , passwd =


'root',database='book_shop')

cur = db.cursor()

print('Add Stock'.center(89 , '='))

bno = unique_book_no()

if bno :

print("Book Number : " , bno)

else :

bno = int(input("Enter book number : "))

bname = input("Enter the Book\'s Name : ")

auth = input("Enter the Author of the Book : ")

publ = input("Enter the Publisher of the Book : ")

cost = eval(input("Enter the Cost per Book : "))

stock = int(input("Enter the Quantity purchased : "))

cur.execute("insert into stock values ({} , '{}' , '{}' , '{}' , {} , {} , {} ,


'{}')".format(bno , bname , auth , publ , cost , stock , 0, dt.date.today()))

print("Inserted Sucessfully !!!")

db.commit()

db.close()

def unique_book_no () :

db = cntr.connect(host = 'localhost' , user = 'root' , passwd =


'root',database='book_shop')

cur = db.cursor()
cur.execute("select max(Book_No) from stock")

data = cur.fetchall()

if bool(data[0][0]) :

L1 = [x for x in range((data[0][0] + 1) , (data[0][0] + 10000))]

shuffle(L1)

return L1.pop(0)

else :

return False

db.close()

def view_stock() :

db = cntr.connect(host = 'localhost' , user = 'root' , passwd =


'root',database='book_shop')

cur = db.cursor()

cur.execute("select Book_No , Book_Name , Available_Stock from stock")

data = cur.fetchall()

print("Book Number\tBook Name\tStock")

for row in data :

print(row[0] , '\t\t' , row[1] , '\t' , row[2])

db.close()

def update_stock() :

db = cntr.connect(host = 'localhost' , user = 'root' , passwd =


'root',database='book_shop')

cur = db.cursor()
bno = int(input("Enter the book number : "))

cur.execute("select Book_Name , Available_Stock from stock where


Book_No = {}".format(bno))

data = cur.fetchall()

print("Book Name : " , data[0][0])

print("Available Stock : " , data[0][1])

stock = int(input("Enter the new stock purchased : "))

cur.execute("update stock set Available_Stock = Available_Stock +


{}".format(stock))

print("Updated Successfully")

db.commit()

db.close()

def sell_book() :

db = cntr.connect(host = 'localhost' , user = 'root' , passwd =


'root',database='book_shop')

cur = db.cursor()

print('Purchase')

cname = input("Enter the Customer Name : ")

phno = int(input("Enter the phone number : "))

bno = int(input("Enter book number : "))

bname = input("Enter the name of the book : ")

cost = eval(input("Enter the cost of the book : "))

cur.execute("insert into purchased values({} , '{}')".format(bno ,


dt.date.today()))

cur.execute("update stock set qty_purchased = qty_purchased + 1 where


Book_No = {}".format(bno))
cur.execute("update stock set Available_Stock = Available_Stock - 1 where
Book_No = {}".format(bno))

print("Bought Successfully")

db.commit()

q = "Book Shop\nName : {}\nPhone No : {}\nBook Number : {}\nBook


Name : {}\nCost : {}\nDate Of Purchase : {}".format(cname , phno , bno ,
bname , cost ,dt.date.today())

filename = mktemp('.txt')

open(filename , 'w').write(q)

startfile(filename , 'print')

cur.execute('select Book_Name , Book_No , Author from stock where


Available_Stock = 0')

if cur.rowcount == 1 :

print("STOCK OF ")

print("Book Name : " , cur.fetchall()[0][0])

print("Book Number : " , cur.fetchall()[0][1])

print("Author : " , cur.fetchall()[0][2])

print("EXHAUSTED")

cur.execute('delete from stock where Available_Stock = 0')

db.close()

clrscreen = lambda : system("cls")

#Function to get last date of month

def last_month(month , year):


if month in (1,3,5,7,8,10,12) :

return 31

elif month == 2 and is_leapyear(year) :

return 29

elif month == 2 :

return 28

else :

return 30

#Function to check is it leap year

is_leapyear = lambda year : year % 4 == 0 and year % 400==0

def view_sales () :

db = cntr.connect(host = 'localhost' , user = 'root' , passwd =


'root',database='book_shop')

cur = db.cursor()

print('Overall Sales This Month')

cur.execute("select distinct(s.Book_Name) , s.qty_purchased from stock s ,


purchased p where s.Book_No = p.Book_No and p.purchased_on between
'{year}-{month}-01' and '{year}-{month}-{date}'".format(year
=dt.date.today().year , month =dt.date.today().month , date =
last_month(dt.date.today().month ,dt.date.today().year)))

data = cur.fetchall()

L1 , L2 = [] , []

for row in data :


L1.append(row[0])

L2.append(row[1])

print(L1,L2)

'''

plt.bar(L1 , L2)

plt.xlabel('Books')

plt.ylabel('Sales')

plt.title('Sales')

plt.show()

'''

#_______________________________________________________________
____________________

# PYTHON MODULE : Tables_in_mysql

import mysql.connector as cntr

import datetime as dt

from random import shuffle

from tempfile import mktemp

from os import system , startfile

db = cntr.connect(host = 'localhost' , user = 'root' , passwd = 'root')

cur = db.cursor()

cur.execute("create database if not exists book_shop")

cur.execute("use book_shop")
cur.execute("create table if not exists stock\

(Book_No bigint primary key,\

Book_Name varchar(255),\

Author varchar(255),\

Publisher varchar(255),\

Cost_per_Book float,\

Available_Stock bigint,\

qty_purchased bigint,\

purchased_on date)")

cur.execute("create table if not exists users (username varchar(255)


check(username<>'admin1'),password varchar(255))")

cur.execute("create table if not exists purchased (Book_no bigint ,


purchased_on date , foreign key (Book_no) references stock(Book_No))")

#cur.execute("create unique index Book_Index on stock(Book_No)")

print("Database and Tables created successfully")

c = input("Press any key to continue---->")

cur.close()

db.commit()

db.close()

# PYTHON MODULE : main

c = 'y'

while c.lower() == 'y' :


print("Book Shop Management".center(89 , '='))

print('1. Register')

print('2. Login')

print('3. Exit')

cho = int(input("Enter the serial number of your choice : "))

if cho == 1 :

clrscreen()

add_user()#ok

elif cho == 2 :

clrscreen()

if login():#ok

print("Login successful")

clrscreen()

C = 'y'

while C.lower() == 'y' :

clrscreen()

print("Book Shop Management".center(89 , '='))

print("1. Book Stock")#ok

print("2. Book Selling")

print("3. Exit")#ok

choice = int(input("Enter the serial number of your choice : "))

if choice == 1 :

clrscreen()

print("Book Book".center(89 , '='))


print("1. Add a new Stock")#ok

print("2. View all Stock")#ok

print("3. Update an existing Stock")

print("4. Exit")

choice2 = int(input("Enter the choice : "))

if choice2 == 1 :

clrscreen()

add_stock()#ok

elif choice2 == 2 :

clrscreen()

view_stock()#ok

elif choice2 == 3 :

clrscreen()

update_stock()#ok

elif choice2 == 4 :

print("Good Bye")

break

else : print("INVALID CHOICE")

elif choice == 2 :

clrscreen()

print('Book Selling'.center(89 , '='))

print('1. Sell a book')

print('2. View Sales this month')

print("3. Exit")
choice3 = int(input("Enter your choice : "))

if choice3 == 1 :

clrscreen()

sell_book()

elif choice3 == 2 :

clrscreen()

view_sales()

elif choice3 == 3 :

print("Good Bye")

break

else : print("INVALID CHOICE")

elif choice == 3 :

print("Good Bye")

break

else : print("INVALID CHOICE")

C = input("Do you want to continue (y/[n]) : ")

else : print("Good Bye")

else :

print("Either your username or password is incorrect")

elif cho == 3 :

print("Good Bye")

break

else :

print("INVALID CHOICE")
c = input("Do you want to return to main menu (y/[n]) : ")

else :

print("Good Bye")

OUTPUT SCREEN
BIBLIOGRAPHY

1. http://www.google.com/
2. http://en.wikipedia.org

3. Computer science with python

by Sumita Arora

You might also like