Book Management System
Book Management System
COD,JABALPUR
SESSION 2024-25
SUBMITTED TO SUBMITTED BY
TABLE OF CONTENT
1 Certificate -
2 Acknowledgement -
3 Package/Module Used 5
4 Coding 7
5 Output 14
6 Limitation 16
7 Requirements 16
8 Bibliography 17
Certificate
Date:
PRINCIPAL’s SIGNATURE:
___________________
Acknowledgement
guide teacher Mrs. Archana Patel (PGT (CS)), for his expert help &
our sincere gratitude to one and all who directly or indirectly have lent
Existing System –
The BOOK MANAGEMENT Shop used manual record
keeping. We visited the shop 3-4 times to observe and
understand the day-to-day working of the shop to
analyze the type of information kept in the manual
way. It was observed that keeping all records manually
caused many issues –
Lack of proper record of the books available in the
shop Mismatch of the purchase details leading to
wrong billing
Incomplete data about book store,
Proposed System –
The proposed system aims to convert manual record
keeping to computer automation with the use of
Python as user interface and backend as MySQL. The
proposed benefits of the computerized system are -
Digitally record details of all the products available in
the shop
Complete data of all the books along with number of
books purchased
Details of the books in the shop.
CODING
# PYTHON MODULE : BOOK
import mysql.connector
from mysql.connector import errorcode
from datetime import date, datetime, timedelta
from mysql.connector import (connection)
import os
import platform
def MenuBook():
while True:
clrscreen()
print("\t\t\t Book Record Management\n")
print("===========================================================
===")
print("1. Add Book Record ")
print("2. Display Book Records ")
print("3. Search Book Record ")
print("4. Delete Book Record ")
print("5. Update Book Record ")
print("6. Return to Main Menu ")
print("===========================================================
====")
choice=int(input("Enter Choice between 1 to 5-------> : "))
if choice==1:
insertData()
elif choice==2:
display()
elif choice==3:
SearchBookRec()
elif choice==4:
deleteBook()
elif choice==5:
UpdateBook()
elif choice==6:
return
else:
print("Wrong Choice. Enter Your Choice again")
x=input("Enter any key to continue")
def clrscreen():
if platform.system()=="Windows":
print(os.system("cls"))
def display():
try:
os.system('cls')
cnx = connection.MySQLConnection(user='root', password='',
host='localhost',database='book1')
Cursor = cnx.cursor()
query = ("SELECT * FROM BookRecord")
Cursor.execute(query)
for (Bno,Bname,Author,price,publ,qty,d,m,y) in Cursor:
print("===========================================================
===")
print("Book Code : ",Bno)
print("Book Name : ",Bname)
print("Author of Book : ",Author)
print("Price of Book : ",price)
print("Publisher : ",publ)
print("Total Quantity in Hand : ",qty)
print("Purchased On : ",d,"/",m,"/",y,"/")
print("===========================================================
====")
Cursor.close()
cnx.close()
print("You have done it!!!!!!")
except mysql.connector.Error as err:
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif err.errno == errorcode.ER_BAD_DB_ERROR:
print("Database does not exist")
else:
print(err)
#else:
cnx.close()
def insertData():
try:
cnx = connection.MySQLConnection(user='root',password="",
host='localhost',database='book1')
Cursor = cnx.cursor()
bno=input("Enter Book Code : ")
bname=input("Enter Book Name : ")
Auth=input("Enter Book Author's Name : ")
price=int(input("Enter Book Price : "))
publ=input("Enter Publisher of Book : ")
qty=int(input("Enter Quantity purchased : "))
print("Enter Date of Purchase (Date/MOnth and Year seperately: ")
DD=int(input("Enter Date : "))
MM=int(input("Enter Month : "))
YY=int(input("Enter Year : "))
Qry = "INSERT INTO BookRecord VALUES({},'{}','{}',{},'{}',{},{},{},
{})".format(bno,bname,Auth,price,publ,qty,YY,MM,DD)
Cursor.execute(Qry)
# Make sure data is committed to the database
cnx.commit()
Cursor.close()
cnx.close()
print("Record Inserted ")
except mysql.connector.Error as err:
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif err.errno == errorcode.ER_BAD_DB_ERROR:
print("Database does not exist")
else:
print(err)
cnx.close()
def deleteBook():
try:
cnx = connection.MySQLConnection(user='root',password="",
host='localhost',database='book1')
Cursor = cnx.cursor()
bno=input("Enter Book Code of Book to be deleted from the Library : ")
Qry =("""DELETE FROM BookRecord WHERE BNO = %s""")
del_rec=(bno,)
Cursor.execute(Qry,del_rec)
# Make sure data is committed to the database
cnx.commit()
Cursor.close()
cnx.close()
print(Cursor.rowcount,"Record(s) Deleted Successfully ")
except mysql.connector.Error as err:
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif err.errno == errorcode.ER_BAD_DB_ERROR:
print("Database does not exist")
else:
print(err)
cnx.close()
def SearchBookRec():
try:
cnx = connection.MySQLConnection(user='root',password="",
host='localhost',database='book1')
Cursor = cnx.cursor()
bno=input("Enter Book No to be Searched from the Library : ")
query = ("SELECT * FROM BookRecord where BNo = %s ")
rec_srch=(bno,)
Cursor.execute(query,rec_srch)
Rec_count=0
for (Bno,Bname,Author,price,publ,qty,d,m,y) in Cursor:
Rec_count+=1
print("===========================================================
===")
print("Book Code : ",Bno)
print("Book Name : ",Bname)
print("Author of Book : ",Author)
print("Price of Book : ",price)
print("Publisher : ",publ)
print("Total Quantity in Hand : ",qty)
print("Purchased On : ",d,"/",m,"/",y,"/")
print("===========================================================
====")
if Rec_count%2==0:
input("Press any key to continue")
clrscreen()
print(Rec_count, "Record(s) found")
# Make sure data is committed to the database
cnx.commit()
Cursor.close()
cnx.close()
except mysql.connector.Error as err:
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif err.errno == errorcode.ER_BAD_DB_ERROR:
print("Database does not exist")
else:
print(err)
cnx.close()
def UpdateBook():
try:
cnx = connection.MySQLConnection(user='root',password="",
host='localhost',database='book1')
Cursor = cnx.cursor()
bno=input("Enter Book Code of Book to be Updated from the Library : ")
query = ("SELECT * FROM BookRecord where BNo = %s ")
rec_srch=(bno,)
print("Enter new data ")
bname=input("Enter Book Name : ")
Auth=input("Enter Book Author's Name : ")
price=int(input("Enter Book Price : "))
publ=input("Enter Publisher of Book : ")
qty=int(input("Enter Quantity purchased : "))
print("Enter Date of Purchase (Date/MOnth and Year seperately: ")
DD=int(input("Enter Date : "))
MM=int(input("Enter Month : "))
YY=int(input("Enter Year : "))
Cursor.execute(Qry,data)
# Make sure data is committed to the database'''
cnx.commit()
Cursor.close()
cnx.close()
print(Cursor.rowcount,"Record(s) Updated Successfully ")
except mysql.connector.Error as err:
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif err.errno == errorcode.ER_BAD_DB_ERROR:
print("Database does not exist")
else:
print(err)
cnx.close()
#UpdateBook()
MenuBook()
OUTPUTS
LIMITATION
www.cbseportal.com
2. https://www.geeksforgeeks.org/
3. https://www.w3schools.com/python/python_classes.asp
4. http://python.mykvs.in/