Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

PM SHRI KENDRIYA VIDYALAYA BAIRAGARH

[Session 2023-24]

Informatics Practices Project


“LIBRARY MANAGEMENT SYSTEM”

Submitted to: Submitted by:


Mr. Hemant Soni Vaibhav Chourasia
(PGT Computer Science) Class- XII A
Certificate

This is to certify that Vaibhav Chourasia of class XII A has


successfully completed the IP Investigatory Project on the topic
"Library Management System" under the guidance of Mr. Hemant
Soni PGT Computer Science as a part practical during the session
2023-24. He has taken proper care & utmost sincerity in completion
of his project all the work related to the project was done by the
candidate himself. This project as per the guidance issued by CBSE.

Internal Examiner External Examiner

_______________ _______________

Principal Sign

_______________
Acknowledgement

I would like to express my special thanks and gratitude to my teacher


& guide Mr. Hemant Soni sir who guided, encouraged and
monitored me throughout the project. I would also like to thank my
principal sir Sh. B.K. Bachle, who gave me the opportunity to do the
project on the topic "Library Management System" and also
provided his cordial support and necessary facilities.

Date: 15-12-2023 Vaibhav Chourasia


Class XII A
Index

Sr. No. Content Page


No.
1 System development life cycle 1

2 Project Analysis 2

3 System Requirements 2

4 Functions and Modules 3

5 Project Description 4

6 Functionalities of a system 5

7 Source Code 6-12

8 Output: 13-16

8.1 (i) Book Details 13

8.2 (ii) Member Details 14

8.3 (iii) Transaction 15

8.4 (iv) Report 16

9 Bibliography 17

0
System Development Life Cycle

The systems development life cycle is a project management


technique that divides complex projects into smaller, more
easily managed segments or phases. Segmenting projects
allows managers to verify the successful completion of project
phases before allocating resources to subsequent phases.
Software development projects typically include initiation,
planning, design, development, testing, implementation, and
maintenance phases. However, the phases may be divided
differently depending on the organization involved.
For example, initial project activities might be designated as
request, requirements-definition, and planning phases, or
initiation, concept-development, and planning phases. End
users of the system under development should be involved in
reviewing the output of each phase to ensure the system is
being built to deliver the needed functionality

1
Project Analysis

Our application program is specifically designed for the public


library named “The Classic Readers.” They lend books to the
readers who have subscribed with the library.
We have tried to maximise the efficiency and strived for the
user ease as well as satisfaction. We have thoroughly
examined the needs of the library and after the analysis, we
have constructed the program.
We have used PYTHON (for interface) and MYSQL (for storing
the data) as our platform to carry out this task.

System Requirements
Processor: P-IV and Above
RAM: 1GB
Windows: 7 and above
Python Version: 3.6 and above
MySQL Version: 5.6 and above

2
Functions and Modules

Modules:
Import mysql.connector:
By importing this package, we are able to establish the
connection between SQL and Python.

Functions:

connect(): This function establishes connection between


Python and MySQL
cursor(): It is a special control structure that facilitates the row-
by-row processing of records in the result set. The Syntax is:
<cursor object>=<connection object>.cursor()
execute(): This function is used to execute the SQL query and
retrieve records using python. The syntax is:
<cursor object>.execute(<SQL query string>)
def(): A function is a block of code which only runs when it is
called.
fetchall(): This function will return all the rows from the result
set in the form of a tuple of containing the records.
fetchone(): This function will return one row from the result set
in the form of a tuple containing the records.
commit(): This function provides in the database physically.

3
Project Description
(Database Architecture)

LIBRARY

This project has 4 MySQL tables:


1. Book
2. Member
3. Issue
4. Report

Book

Member

Issue Returns

4
Functionalities of the system
You can perform the following actions in our program:

Book Details:
1. Add New Book
2. Edit Book Details
3. Delete a Book
4. Search A Book

Member Details:
1. Add A New Member
2. Edit A Member
3. Delete A Member
4. Search A Member

Transactions:
1. Issue a book
2. Return a book

Reports:
1. Book Details
2. Member Details
3. Issue Details
4. Return Details
5. Best Reading Book (chart)

5
Source Code
MySQL
Create database library;
Use library;
Create table book(
BookID int primary key,
BookName varchar(100),
Author varchar(30),
Edditon char(10),
Copies int,
Rem_Copies int);

Create table Member(


MemberID int primary key,
MemName varchar(30),
Email varchar(40),
Phone char(10));

Create table Issue(


Issueid int primary key,
Issuedate date,
BookID int,
MemberID int,
Copies int,
foreign key (BookID) references Book(BookID),
foreign key (MemberID) references Member(MemberID));

Create table Returns(


Returnid int primary key,
Returndate date,
BookID int,
MemberID int,
Copies int,
foreign key (BookID) references Book(BookID),
foreign key (MemberID) references Member(MemberID));

6
Python
import mysql.connector as sqlt
import pandas as pd
from tabulate import tabulate
import matplotlib.pyplot as plt

con = sqlt.connect(host= "localhost", user = "root", password = "password", database = "library")


cursor = con.cursor()

#Book
def book_input():
try:
bookid = input("Enter Book id: ")
bookName = input("Enter Book Name: ")
author = input("Enter Author Name: ")
eddition = float(input("Enter Eddition: "))
copies = int(input("Enter No of Copies: "))
qry = "insert into book value({},'{}','{}','{}',{},{});".format(bookid,bookName,author,eddition,copies,copies)
cursor.execute(qry)
con.commit()
print("added successfully")
except:
print("Sorry, Something Went Wrong!!")

def book_edit():
try:
x=int(input("Enter Book ID: "))
qry= "select* from book where bookid = {};".format(x)
cursor.execute(qry)
r=cursor.fetchone()
if r:
y=float(input("Enter New Eddition: "))
qry = "select * from book where bookid= {};".format(y,x)
cursor.execute(qry)
print("Edited sussessfully.")
else:
print("Book ID Doesn't exists.")
except:
print("Sorry, Something Went Wrong!!")

def book_delete():
try:
x=int(input("Enter Book ID: "))
qry= "select * from book where bookid = {};".format(x)
cursor.execute(qry)
r=cursor.fetchone()
if r:
qry = "delete from book where bookid= {};".format(x)
cursor.execute(qry)
con.commit()
print("Deleted sussessfully.")
else:

7
print("Book ID Doesn't exists.")
except:
print("Sorry, Something Went Wrong!!")

def book_search():
try:
x=int(input("Enter Book ID: "))
qry= "select* from book where bookid = {};".format(x)
cursor.execute(qry)
r=cursor.fetchone()
if r:
df=pd.read_sql(qry,con)
print(tabulate(df, headers = 'keys' , tablefmt = 'psql', showindex =True))
else:
print("Book ID Doesn't exists.")
except:
print("Sorry, Something Went Wrong!!")

#Member
def member_input():
try:
memberid = input("Enter Member ID: ")
MemName = input("Enter Name: ")
Email = input("Enter Email: ")
Phone = float(input("Enter Phone No.: "))
qry = "insert into member value({},'{}','{}','{}');".format(memberid, MemName, Email, Phone)
cursor.execute(qry)
con.commit()
print("added successfully")
except:
print("Sorry, Something Went Wrong!!")

def member_edit():
try:
x=int(input("Enter Member ID: "))
qry= "select* from member where memberid = {};".format(x)
cursor.execute(qry)
r=cursor.fetchone()
if r:
y=input("Enter New Email: ")
qry = "update member set Email ='{}' where memberid= {};".format(y,x)
cursor.execute(qry)
print("Edited sussessfully.")
else:
print("Member ID Doesn't exists.")
except:
print("Sorry, Something Went Wrong!!")

def member_delete():
try:

8
x=int(input("Enter Member ID: "))
qry= "select* from member where memberid = {};".format(x)
cursor.execute(qry)
r=cursor.fetchone()
if r:
qry = "delete from member where memberid= {};".format(x)
cursor.execute(qry)
print("Deleted sussessfully.")
else:
print("Book ID Doesn't exists.")
except:
print("Sorry, Something Went Wrong!!")

def member_search():
try:
x=int(input("Enter Member ID: "))
qry= "select* from member where memberid = {};".format(x)
cursor.execute(qry)
r=cursor.fetchone()
if r:
df=pd.read_sql(qry,con)
print(tabulate(df, headers = 'keys' , tablefmt = 'psql',showindex =False))
else:
print("Member ID Doesn't exists.")
except:
print("Sorry, Something Went Wrong!!")

#Transactions
def book_issue():
try:
q = "select max(issueid) from issue;"
cursor.execute(q)
r = cursor.fetchone()[0]
if r:
issueid = r+1
else:
issueid = 1
x=int(input("Enter Member ID: "))
q1 = "select * from member where memberid = {};".format(x)
cursor.execute(q1)
r=cursor.fetchone()
if r:
y = int(input("Enter Book ID: "))
q2 = "select bookid, rem_copies from book where bookid = {};".format(y)
cursor.execute(q2)
r=cursor.fetchone()
if r:
if r[1] > 0:
issuedate = input("Enter Issue Date(YYYY-MM-DD): ")
copies = int(input("Enter Number of Copies: "))
remcopies = r[1] - copies
q3 = "insert into issue values({},'{}',{},{},{})".format(issueid, issuedate, x,y,copies)

9
cursor.execute(q3)
q4 = "update book set rem_copies = {} where bookid = {};".format(remcopies,y)
cursor.execute(q4)
con.commit()
print("Book Issued Successfully...")
else:
print("Book is Not Available :( ")
else:
print("Wrong Book ID!")
else:
print("Wrong Member ID!")
except:
print("Sorry, Something Went Wrong!!")

def book_return():
try:
q = "select max(returnid) from returns;"
cursor.execute(q)
r = cursor.fetchone()[0]
if r:
returnid = r+1
else:
returnid = 1
x=int(input("Enter Your Member ID: "))
q1 = "select * from member where memberid = {};".format(x)
cursor.execute(q1)
r=cursor.fetchone()
if r:
y = int(input("Enter Your Book ID: "))
q2 = "select bookid, rem_copies from book where bookid = {};".format(y)
cursor.execute(q2)
r=cursor.fetchone()
if r:

returndate = input("Enter Issue Date (in YYYY-MM-DD): ")


copies = int(input("Enter Number of Copies: "))
remcopies = r[1] + copies
q3 = "insert into returns values({},'{}',{},{},{})".format(returnid, returndate, x,y,copies)
cursor.execute(q3)
q4 = "update book set rem_copies = {} where bookid = {};".format(remcopies,y)
cursor.execute(q4)
con.commit()
print("Book Returned Successfully...")

else:
print("Wrong Book ID!")
else:
print("Wrong Member ID!")
except:
print("Sorry, Something Went Wrong!!")

10
#Report
def book_output():
df = pd.read_sql("select * from book",con)
print(tabulate(df, headers = 'keys', tablefmt = 'psql', showindex= False))

def member_output():
df= pd.read_sql("select * from member",con)
print(tabulate(df, headers = 'keys' , tablefmt = 'psql', showindex = False))

def issue_output():
df = pd.read_sql("select * from issue",con)
print(tabulate(df, headers = 'keys', tablefmt = 'psql', showindex= False))

def return_output():
df = pd.read_sql("select * from returns",con)
print(tabulate(df, headers = 'keys', tablefmt = 'psql', showindex= False))

def col_chart():
q = "select bookid, count(copies) as totalcopies from issue group by bookid;"
df = pd.read_sql(q,con)
print(df)
plt.bar(df.bookid, df.totalcopies)
plt.xlabel("BookID")
plt.ylabel("Copies Issued")
plt.title("Best Reading Book")
plt.xticks(df.bookid)
plt.show()

while(True):
print("="*80)
print("\t\t\t-------LIBRARY MANAGEMENT SYSTEM-------\n")
print("="*80)
print("\t\t\t\tEnter Your Choice\n\t\t\t\t(1).Book Datails\n\t\t\t\t(2).Member
Datails\n\t\t\t\t(3).Transactions\n\t\t\t\t(4).Report\n\t\t\t\t(5).Exit")
choice = int(input())
if choice == 1:
while(True):
print("\t\t\t\tBᴏᴏᴋ Dᴇᴛᴀɪʟꜱ:\n\t\t\t\t(1).Add Book Details\n\t\t\t\t(2).Edit Book Datails\n\t\t\t\t(3).Delete
A book\n\t\t\t\t(4).Search A Book\n\t\t\t\t(5).Exit")
ch = int(input())
if ch == 1:
book_input()
elif ch == 2:
book_edit()
elif ch == 3:
book_delete()
elif ch == 4:
book_search()
elif ch == 5:
break
elif choice == 2:

11
while(True):
print("\t\t\t\tMᴇᴍʙᴇʀ Dᴀᴛᴀɪʟꜱ:\n\t\t\t\t(1).Add member Datails\n\t\t\t\t(2).Edit Member
Details\n\t\t\t\t(3).Delete A Member\n\t\t\t\t(4).Search A Member\n\t\t\t\t(5).Back to main menue")
ch = int(input())
if ch == 1:
member_input()
elif ch == 2:
member_edit()
elif ch == 3:
member_delete()
elif ch == 4:
member_search()
elif ch==5:
break
elif choice == 3:
while(True):
print("\t\t\t\tTʀᴀɴꜱᴀᴄᴛɪᴏɴꜱ:\n\t\t\t\t(1).Issue Book\n\t\t\t\t(2).Return Book\n\t\t\t\t(3).Back to main
menue")
ch = int(input())
if ch == 1:
book_issue()
elif ch == 2:
book_return()
elif ch == 3:
break
elif choice == 4:
while(True):
print("\t\t\t\tRᴇᴘᴏʀᴛ:\n\t\t\t\t(1).Book Details\n\t\t\t\t(2).Member Details\n\t\t\t\t(3).Issue
Details\n\t\t\t\t(4).Return Details\n\t\t\t\t(5).Best Reading Book (bar chart)\n\t\t\t\t(6).Back to main menue")
ch = int(input())
if ch == 1:
book_output()
elif ch == 2:
member_output()
elif ch == 3:
issue_output()
elif ch == 4:
return_output()
elif ch == 5:
col_chart()
elif ch == 6:
break
elif choice == 5:
break

12
Output
BOOK DETAILS
Adding details of a book

Editing Book Details

Deleting a Book Details

Searching a Book Details

13
MEMBER DETAILS

Adding details of a member

Editing details of a member

Deleting details of a member

Searching details of a member

14
TRANSACTIONS
Issuing a book

Returning a book

15
REPORT
Book Details (table)

Member details (table)

Best Reading Book (graph)

16
Bibliography

To develop this project many references were used:


1. Informatics Practices Class XII – Preeti Arora
2. https//www.google.com/
3. https://www.youtube.com/
4. https://docs.python.org/3/
5. https://dev.mysql.com/doc/

17

You might also like