Exam Pass
Exam Pass
COMPUTER INVESTIGATORY
PROJECT 2022-2023
BOOK STALLMANAGEMENT
COMPUTER INVESTIGATORY
PROJECT 2022-2023
BOOK STALLMANAGEMENT
Department of Computer
Hardware Requirements:
➢ Processor : Dual core or Above
➢ Hard Disk : 50GB or above
➢ RAM : 2GB or more
Software Requirements:
➢ Operating system : Windows 7/8/10 or
Linux ➢ Platform : IDLE Python 3.10
➢ Database : MySQL
➢ Languages : Python 3.10
➢ Microsoft Word
INTRODUCTION:
_ _ d b = c n t r. c o n n e c t ( h o s t = 'localhost' , u s e r = 'root' , p a s s w d
= 'manager' , database = 'book_shop')
__cur = __db.cursor()
__db.autocommit(True)
# F u n c t i o n t o c h e c k is it l e a p y e a r
is_leapyear = lambda year : year % 4 = = 0
def view_stock() :
_ _c ur.e xecu te( " selec t B o o k _ N o , B o o k _ N a m e , Av a i l a b l e _ S t o c k
from stock")
d a t a = _ _ c u r. f e t c h a l l ( )
print("Book N u m b e r \tBook N a m e \tStock")
f o r r o w i n d a t a : p r i n t ( r o w [ 0 ] , '\ t \ t' , r o w [ 1 ] , '\ t' ,
row[2])
def add_stock() :
print('Add Stock'.center(89 , '='))
b n o = unique_book_no()
if b n o :
print("Book Number : " , bno)
else : b n o = int(input("Enter b o o k n u m b e r : "))
b n a m e = i n p u t ( " E n t e r t h e B o o k \'s N a m e : " )
auth = input("Enter the Author of the B o o k : ")
publ = input("Enter the Publisher of the B o o k : ")
cost = eval(input("Enter the Cost per B o o k : "))
stock = int(input("Enter the Quantity purchased : "))
_ _ c u r. e x e c u t e ( " i n s e r t i n t o s t o c k v a l u e s ( { } , '{}' , '{}' ,
'{}' , { } , { } , { } , '{}')".format(bno , b n a m e , auth , p u b l ,
cost , stock , 0, __dt.date.today()))
print("Inserted Sucessfully !!!")
def add_user() :
user = input("Enter the user n a m e : ")
p a s s w d = input("Enter a P a s s w o r d : ")
p a s s w d 2 = input("Enter P a s s w o r d to confirm : ")
if p a s s w d = = p a s s w d 2 :
_ _ c u r. e x e c u t e ( " i n s e r t i n t o u s e r s v a l u e s ( ' { } ' ,
'{}')".format(user , passwd))
print("Created Successfully!!!")
e l i f p a s s w d ! = p a s s w d 2 : p r i n t ( " Yo u ' v e e n t e r e d d i f f e r e n t
passwords")
def sell_book() :
print('Purchase')
c n a m e = input("Enter the C u s t o m e r N a m e : ")
p h n o = int(input("Enter the p h o n e n u m b e r : "))
b n o = int(input("Enter b o o k n u m b e r : "))
b n a m e = input("Enter the n a m e of the b o o k : ")
cost = eval(input("Enter the cost of the b o o k : "))
_ _ c u r. e x e c u t e ( " i n s e r t i n t o p u r c h a s e d v a l u e s ( { } ,
'{}')".format(bno , __dt.date.today()))
_ _ c u r. e x e c u t e ( " u p d a t e s t o c k s e t q t y _ p u r c h a s e d =
q t y _ p u r c h a s e d + 1 w h e r e B o o k _ N o = { }".f or ma t( bno) )
_ _ c u r. e x e c u t e ( " u p d a t e s t o c k s e t Av a i l a b l e _ S t o c k =
Av a i l a b l e _ S t o c k - 1 w h e r e B o o k _ N o = { } " . f o r m a t ( b n o ) )
print("Bought Successfully")
q = '''Book S h o p \n N a m e : { } \n P h o n e N o : { } \n B o o k N u m b e r :
{ } \n B o o k N a m e : { } \n C o s t : { } \n D a t e O f P u r c h a s e :
{}'''.format(cname , phno , bno , b n a m e , cost ,
__dt.date.today())
filename = mktemp('.txt')
open(filename , 'w').write(q)
startfile(filename , 'print')
_ _c ur.e xecu te( 'sele c t B o o k _ N a m e , B o o k _ N o , A u t h o r f r o m
s t o c k w h e r e Av a i l a b l e _ S t o c k = 0 ' )
i f _ _ c u r. r o w c o u n t = = 1 :
print("STOCK O F ")
p r i n t ( " B o o k N a m e : " , _ _ c u r. f e t c h a l l ( ) [ 0 ] [ 0 ] )
p r i n t ( " B o o k N u m b e r : " , _ _ c u r. f e t c h a l l ( ) [ 0 ] [ 1 ] )
p r i n t ( " A u t h o r : " , _ _ c u r. f e t c h a l l ( ) [ 0 ] [ 2 ] )
print("EXHAUSTED")
_ _ c u r. e x e c u t e ( ' d e l e t e f r o m s t o c k w h e r e Av a i l a b l e _ S t o c k
= 0')
d e f u n i q u e _ b o o k _ n o () :
_ _ c u r. e x e c u t e ( " s e l e c t m a x ( B o o k _ N o ) f r o m s t o c k " )
d a t a = _ _ c u r. f e t c h a l l ( )
if b o o l ( d a t a [ 0 ] [ 0 ] ) :
L 1 = [x for x in range((data[0][0] + 1) , (data[0][0] +
10000))]
shuffle(L1)
return L1.pop(0)
else : return False
def view_sales () :
print('Overall Sales This Month')
_ _ c u r. e x e c u t e ( " s e l e c t d i s t i n c t ( s . B o o k _ N a m e ) ,
s.qty_purchased from stock s , purchased p where s.Book_No =
p . B o o k _ N o a n d p . p u r c h a s e d _ o n b e t w e e n '{year}- { m o n t h } - 01' a n d
'{year}-{ m o n t h } -{date}'".format(year = __dt.date.today().year ,
month = __dt.date.today().month , date =
last_month(__dt.date.today().month , __dt.date.today().year)))
d a t a = _ _ c u r. f e t c h a l l ( )
L 1 , L 2 = [] , []
for r o w in data :
L1.append(r ow[0])
L2.ap p e n d ( r ow[1])
plt.bar(L1 , L2)
plt.xlabel('Books')
plt.ylabel('Sales')
plt.title('Sales')
plt.show()
def login():
user = input("Enter the u s e r n a m e : ")
p w d = input("Enter the password : ")
_ _ c u r. e x e c u t e ( " S e l e c t * f r o m u s e r s w h e r e ( u s e r n a m e = ' { } '
and password = '{}')".format(user , pwd))
if _ _ c u r. r o w c o u n t : r e t u r n Tr u e
def update_stock() :
b n o = int(input("Enter the b o o k n u m b e r : "))
_ _ c u r. e x e c u t e ( " s e l e c t B o o k _ N a m e , Av a i l a b l e _ S t o c k f r o m
s t o c k w h e r e B o o k _ N o = { } " .f orm at( bn o) )
d a t a = _ _ c u r. f e t c h a l l ( )
print("Book N a m e : " , data[0][0])
p r i n t ( " Av a i l a b l e S t o c k : " , d a t a [ 0 ] [ 1 ] )
stock = int(input("Enter the n e w stock purchased : "))
_ _ c u r. e x e c u t e ( " u p d a t e s t o c k s e t Av a i l a b l e _ S t o c k =
Av a i l a b l e _ S t o c k + { } " . f o r m a t ( s t o c k ) )
print("Updated Successfully")
===============================================================
=====
d b = c n t r. c o n n e c t ( h o s t = 'localhost' , u s e r = 'root' , p a s s w d =
'manager')
d b .a u t o commit(True)
cur = db.cursor()
c u r. e x e c u t e ( " c r e a t e d a t a b a s e i f n o t e x i s t s b o o k _ s h o p " )
c u r. e x e c u t e ( " u s e b o o k _ s h o p " )
c u r. e x e c u t e ( " c r e a t e t a b l e s t o c k \
( B o o k _ N o b i g i n t p r i m a r y k e y, \
B o o k _ N a m e varchar(255),\
Author varchar(255),\
Publisher varchar(255),\
C o s t _ p e r _ B o o k float,\
Av a i l a b l e _ S t o c k b i g i n t , \
qty_purchased bigint,\
purchased_on date)")
c u r. e x e c u t e ( " c r e a t e t a b l e u s e r s ( u s e r n a m e v a r c h a r ( 2 5 5 ) ,
password varchar(255) , check (username < > 'ADMIN'))")
c u r. e x e c u t e ( " c r e a t e t a b l e p u r c h a s e d ( B o o k _ n o b i g i n t ,
purchased_on date , foreign key(Book_no) references
stock(Book_No))")
c u r. e x e c u t e ( " c r e a t e u n i q u e i n d e x B o o k _ I n d e x o n s t o c k ( B o o k _ N o ) " )
c u r. e x e c u t e ( " i n s e r t i n t o u s e r s v a l u e s ( ' a d m i n ' , ' a d m i n @ 1 2 3 ' ) " )
p r i n t ( " D a t a b a s e a n d Ta b l e s c r e a t e d s u c c e s s f u l l y " )
c = input("Press a n y k e y to continue---->")
c u r. c l o s e ( )
db.close()
===============================================================
=====
import Book
c = 'y'
w h i l e c . l o w e r ( ) = = 'y' :
p r i n t ( " B o o k S h o p M a n a g e m e n t " . c e n t e r ( 8 9 , '='))
print('1. Register')
print('2. Login')
print('3. E xit')
choice4 = int(input("Enter the serial n u m b e r of your choice
: "))
if c h o i c e 4 = = 1 :
Book.clrscreen()
B o o k . a d d _ u s e r()
elif c h o i c e 4 = = 2 :
Book.clrscreen()
if B o o k . l o g i n ( ) :
Book.clrscreen
C = 'y'
w h i l e C . l o w e r ( ) = = 'y' :
Book.clrscreen()
p r i n t ( " B o o k S h o p M a n a g e m e n t " . c e n t e r ( 8 9 , '='))
print("1. B o o k Stock")
print("2. B o o k Selling")
print("3. Exit")
choice = int(input("Enter the serial n u m b e r of
y o u r choice : "))
if c h o i c e = = 1 :
Book.clrscreen()
p r i n t ( " B o o k B o o k " . c e n t e r ( 8 9 , '='))
print("1. A d d a n e w Stock")
print("2. Vi e w all Stock")
print("3. U p d a t e a n existing Stock")
print("4. Exit")
choice2 = int(input("Enter the choice : "))
if c h o i c e 2 = = 1 :
Book.clrscreen()
B o o k . a d d_sto ck( )
elif c h o i c e 2 = = 2 :
Book.clrscreen()
Bo ok.view_stock()
elif c h o i c e 2 = = 3 :
Book.clrscreen()
Book.update_stock()
elif c h o i c e 2 = = 4 :
print("Good Bye")
b r e ak
else : print("INVALID C H O I C E " )
elif c h o i c e = = 2 :
Book.clrscreen()
print('Book Selling'.center(89 , '='))
print('1. Sell a book')
print('2. Vi e w Sales this month')
print("3. Exit")
choice3 = int(input("Enter your choice :
"))
if c h o i c e 3 = = 1 :
Book.clrscreen()
Book.sell_book()
elif c h o i c e 3 = = 2 :
Book.clrscreen()
Book.view_sales()
elif c h o i c e 3 = = 3 :
print("Good Bye")
b r e ak
else : print("INVALID C H O I C E " )
elif c h o i c e = = 3 :
print("Good Bye")
b r e ak
else : print("INVALID C H O I C E " )
C = input("Do y o u w a n t to continue (y/[n]) : ")
else : print("Good B y e " )
else :
print("Either y o u r u s e r n a m e o r p a s s w o r d is
incorrect")
elif c h o i c e 4 = = 3 :
print("Good Bye")
b r e ak
else : print("INVALID C H O I C E " )
c = input("Do y o u w a n t to return to m a i n m e n u (y/[n]) : ")
===============================================================
OUTPUT
BIBLIOGRAPHY
***