CS Class 12 Project

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 34

LIBRARY MANAGEMENT

SYSTEM
A PROJECT REPORT
SUBMITTED TO
NATIONAL MODEL SENIOR SECONDARY SCHOOL
AFFILIATED TO CBSE FOR THE AISSCE 2023

BY
VARUN S

UNDER THE GUIDANCE OF


Mrs. Thilagavathy Rosana

NATIONAL MODEL
SENIOR SECONDARY SCHOOL
JANUARY
  2023

Page | 1
CERTIFICATE

This is to certify that VARUN.S of class XII –


ANTARCTIC has prepared the report on the project titled
“Library Management System”. The report is the result of
his efforts and endeavors. The report is found worthy of
acceptance as the final project report for the subject Physics.

Countersigned Signature of the Staff


Head of the Institution

Seal                                                  External Examiner

Page | 2
DECLARATION
I hereby declare that the project work entitled “Library
Management System” submitted to the Department of
Physics of National Model Senior Secondary School,
Peelamedu, Coimbatore. This is a bonafide work of Varun S,
Thiru Arvinda Samy, Tarun Raghav S K and Sanjaay J
belonging to XII – ANTARCTIC.

SIGNATURE OF THE STUDENT

NAME OF THE STUDENT 

CLASS AND SECTION

REGISTER NUMBER

Page | 3
ACKNOWLEDGEMENT
I would like to express my sincere thanks and gratitude
to my teacher Mrs. Thilagavathy Rosana as well as our
beloved Principal Mrs. D. Geetha who gave me the golden
opportunity, support and guidance to do this wonderful
project on the topic “Library Management System”.
Secondly, I would also like to thank my parents and friends
who helped me a lot in finishing this project within the limited
time.

Thanks again to all who helped me.

Page | 4
TABLE OF CONTENTS

Chapter No. Title Page No.

Overview

1. Project Synopsis 8

2. Requirements 10

3. Back End Details 11

4. Packages & Functions used in 12


the project
5. Source Code 13
6. Output 31
7. Bibliography 33

Page | 5
OVERVIEW

Python is a high-level, cross-platform, and open-sourced


programming language released under a GPL-compatible
license. Python Software Foundation (PSF), a non-profit
organization, holds the copyright of Python.

Guido Van Rossum conceived Python in the late 1980s. It was


released in 1991 at Centrum Wiskunde & Informatica (CWI) in the
Netherlands as a successor to the ABC language. He named this
language after a popular comedy show called 'Monty Python's
Flying Circus' (and not after Python-the snake).

In the last few years, its popularity has increased immensely.


According to stackoverflow.com recent survey, Python is in the top
three Most Loved Programming Language in 2020.

Python Features :

 Python is an interpreter-based language, which allows the


execution of one instruction at a time.
 Extensive basic data types are supported e.g., numbers (floating
point, complex, and unlimited-length long integers), strings
(both ASCII and Unicode), lists, and dictionaries.
 Variables can be strongly typed as well as dynamic typed.

Page | 6
 Supports object-oriented programming concepts such as class,
inheritance, objects, module, namespace etc.
 Cleaner exception handling support.
 Supports automatic memory management.
 Various built-in and third-party modules, which can be imported
and used independently in the Python application.

Python Advantages :

 Python provides enhanced readability. For that purpose, uniform


indents are used to delimit blocks of statements instead of curly
brackets, like in many languages such as C, C++, and Java.
 Python is free and distributed as open-source software. A large
programming community is actively involved in the
development and support of Python libraries for various
applications such as web frameworks, mathematical computing,
and data science.
 Python is a cross-platform language. It works equally on
different OS platforms like Windows, Linux, Mac OSX, etc.
Hence Python applications can be easily ported across OS
platforms.

Page | 7
PROJECT SYNOPSIS

The main objective of the Library Management system is the


discipline of the planning, organizing and managing the library tasks.
Our project aim at making the task of the library easy. Library
Management is entering the records of a new book and retrieving the
details of book available in the library. We can issue book to the
library member and maintain their records and can also check how
many books are issued and stock available in the library.

In this software we have used python for design and MySQL as


backend.

Library management system have following features

1. Add book details

2. Update and Delete Book Details

3. Search Menu

Page | 8
4. Issue and Return

5. Membership Details

In this program for registering a book we have to provide book


id, book name, book type, author name and price.

In our project we are providing 4 types of searching options.

1. Using book id
2. Using book type
3. Using author name
4. Using book name

Our system used to store and manipulate the details of


membership (add, update, search, delete). Valid book id and
membership id is necessary for book issue and return process. Our
project display a report of currently available books and status of
issued books.

Page | 9
Page | 10
REQUIREMENTS

 MINIMUM HARDWARE REQUIRED :


 Display : LED Monitor or above

 Processor : Pentium Core or above


 Hard Disk : 100GB
 RAM : 1GB

 Keyboard : USB
 Mouse : USB
 SOFTWARE REQUIRED :
 Operating system : Windows 8 or above
 Python IDLE : 3.6 or above

 MySQL : 8.0 or above

Page | 11
BACK END DETAILS

BACK END DETAILS


BACK END : MYSQL SERVER MySQL server provides a
database management system with querying and connectivity
capabilities, as well as the ability to have excellent data structure and
integration with many different platforms..
Database Name : LIBRARY
Table Details :
Table Name : BOOKS, ISSUE_RETURN, MEMBERS

Page | 12
PACKAGES & FUNCTIONS USED IN
THE PROJECT
PACKAGE / MODULE

1. Mysql.connector : To establish the connection between Python


and MySQL.

USER DEFINED FUNCTIONS

add_books() : It is used to add a book.

disp_books() : It is used to display the book details.

search_books() : It is used to search a book details.

upd_book() : It is used to update the details of the book.

del_book() : It is used to delete a book.

add_member() : It is used to add a member.

disp_members() : It is used to display the members.

upd_members() : It is used to update the members.

del_member() : It is used to delete a member.

member_details() : It is used to display the details members.

Page | 13
SOURCE CODE
import mysql.connector
import datetime

con=mysql.connector.connect(
host='localhost',
user='root',
password='1234',
database='library')
cur=con.cursor()
def add_books():
while True:
BNo = int(input("Enter the Book ID : "))
Bname = input("Enter the Book Name : ")
Btype = input("Enter the Book Type : ")
Aname = input("Enter the Author Name : ")
Price = float(input("Enter the Price of the book : "))
status = input("Enter the status of the Book : ")
query = "Insert into books values({},'{}','{}','{}',
{},'{}')".format(BNo, Bname, Btype, Aname, Price, status)
cur.execute(query)
con.commit()
print("Row inserted successfully.")
ch=input("Do you want to enter more records?(y/n)")

Page | 14
if ch=='n':
menu()
def disp_books():
query="select * from books"
cur=con.cursor()
cur.execute(query)
data=cur.fetchall()
print("********Library Management
system********************")

print("***************************************************
*************")
print("Book ID | Book Name | Book Type | Author Name | Price |
status ")
for i in data:
print(i[0],' \t', i[1],' \t', i[2],' \t', i[3],' \t', i[4],' \t', i[5])

menu()

def searchbook_id(x):
query="select * from books where BNo={}".format(x)
cur=con.cursor()
cur.execute(query)
rec=cur.fetchone()

Page | 15
if(cur.rowcount==0):
print("Sorry No record Found, Try Again")
menu()
else:
print("********Library Management
system********************")

print("***************************************************
*************")
print("Book ID", rec[0])
print("Book Name:", rec[1])
print("Book Type:", rec[2])
print("Price:", rec[3])
print("Author Name:", rec[4])
print("Status :",rec[5])

print("***************************************************
*************")
return rec
menu()

def searchbook_name():
x=input("Enter the Book Name")
query="select * from books where Bname='{}'".format(x)
cur=con.cursor()

Page | 16
cur.execute(query)
rec=cur.fetchone()
if(cur.rowcount==0):
print("Sorry No record Found,Try Again")
menu()
else:
print("********Library Management
system********************")

print("***************************************************
*************")
print("Book ID", rec[0])
print("Book Name:", rec[1])
print("Book Type:", rec[2])
print("Price:", rec[3])
print("Author Name:", rec[4])
print("Status :",rec[5])

print("***************************************************
*************")
menu()

def searchbook_type():
x=input("Enter the Book type")
query="select * from books where Btype='{}'".format(x,)

Page | 17
cur=con.cursor()
cur.execute(query)
rec=cur.fetchall()
if(cur.rowcount==0):
print("Sorry No record Found,Try Again")
menu()
else:
print("********Library Management
system********************")

print("***************************************************
*************")
print("Book ID Book Name Book Type Author Name Price
Status")
for i in rec:
print(i[0],'\t',i[1],'\t',i[2],'\t',i[3],'\t',i[4],'\t',i[5])
menu()

def searchbook_name():
x=input("Enter the Book Author Name")
query="select * from books where Aname='{}'".format(x)
cur=con.cursor()
cur.execute(query)
rec=cur.fetchall()
if(cur.rowcount==0):

Page | 18
print("Sorry No record Found,Try Again")
menu()
else:
print("********Library Management
system********************")

print("***************************************************
*************")
print("Book ID Book Name Book Type Author Name Price
Status")
for i in rec:
print(i[0],'\t',i[1],'\t',i[2],'\t',i[3],'\t',i[4],'\t',i[5])
print(rec)
menu()

def search_book():
print("1.search using Book ID")
print("2.search using Book Name")
print("3.search using Book Type")
print("4.search using Book Author Name")
print("Return to main menu")
ch=int(input("Enter your choice"))
if ch==1:
x=int(input("Enter the Book ID"))
searchbook_id(x)

Page | 19
menu()
elif ch==2:
searchbook_name()
elif ch==3:
searchbook_type()
elif ch==4:
searchbook_name()
elif ch==5:
menu()

def upd_book():
x=input("Enter the Book ID to Update :")

print("*============================================
========================*")
query="select * from books where BNo='{}' ".format(x)
cur.execute(query)
i=cur.fetchone()
if(cur.rowcount==0):
print("Sorry No Book Found")
a=input("Do you want to Try Again?(yes/no) ")
if a=='no' or a=='NO' or a=='No':

Page | 20
menu()
else:
upd_book()

else:
price=float(input("Enter the price of the book:"))
query="update books set Price={} where
BNo={}".format(price,x)
cur.execute(query)
con.commit()
print("Updated Successfully")
menu()

def del_book():
x=input("Enter Book ID to be Delete: ")
a=input("Are you sure for deleting?(yes/no) ")
print(" ")
if a=='yes' or a=='YES' or a=='Yes':
query="delete from books where BNo='{}'".format(x)
cur.execute(query)
con.commit()
print("\n", x, "Deleted Successfully")
menu()

Page | 21
else:
menu()
def book_details():
print("1.Add Book")
print("2.Display Books")
print("3.Search Book")
print("4.Update Book")
print("5.Delete Book")
print("6.Return To Main Menu")
ch=int(input("Enter your choice:"))
if(ch==1):
add_books()
elif(ch==2):
disp_books()
elif(ch==3):
search_book()
elif(ch==4):
upd_book()
elif(ch==5):
del_book()
elif(ch==6):
menu()

Page | 22
def add_member():
while True:
MNo=int(input("Enter the Member ID:"))
Mname=input("Enter the Member Name:")
Address=input("Enter the Address:")
Contact=input("Enter the Contact Number:")
query="Insert into members
values({},'{}','{}','{}')".format(MNo, Mname, Contact, Address)
cur.execute(query)
con.commit()
print("Row inserted successfully..")
ch=input("Do you want to enter more records?(y/n)")
if ch=='n':
menu()

def disp_members():
cur.execute("select * from members")
for rec in cur:
print("********Library Management
system********************")

print("***************************************************
*************")
print("Member ID:", rec[0])
print("Member Name:", rec[1])

Page | 23
print("Address:", rec[2])
print("Contact:", rec[3])

print("***************************************************
*************")
menu()

def search(x):
x=int(input("Enter the Member ID"))
query="select * from members where MNo={}".format(x)
cur.execute(query)
rec=cur.fetchone()
if(cur.rowcount==0):
print("Sorry No record Found,Try Again")
menu()
else:
print("********Library Management
system********************")

print("***************************************************
*************")
print("Member ID", rec[0])
print("Member Name:", rec[1])
print("Address:", rec[2])

Page | 24
print("Contact:", rec[3])

print("***************************************************
*************")
return rec
menu()

def upd_member():
x=input("Enter the Member ID to Update :")

print("*============================================
========================*")
query="select * from members where MNo='{}' ".format(x)
cur.execute(query)
i=cur.fetchone()
if(cur.rowcount==0):
print("Sorry No Member Found")
a=input("Do you want to Try Again?(yes/no) ")
if a=='no' or a=='NO' or a=='No':
menu()
else:
upd_member()
else:
name=input("Enter the Member Name:")
address=input("Enter the Address:")

Page | 25
contact=input("Enter the Contact Number:")
query="update members set
name='{}',address='{}',contact='{}'where MNo={}".format(name,
address, contact, x)
cur.execute(query)
con.commit()
print("Updated Successfully")
menu()

def del_member():
x=input("Enter Member ID to be Delete: ")
a=input("Are you sure for deleting?(yes/no) ")

print(" ")
if a=='yes' or a=='YES' or a=='Yes':
query="delete from members where MNo='{}'".format(x)
cur.execute(query)
con.commit()
if(cur.rowcount==0):
print("Sorry No Member Found")
menu()
else:
print("\n", x, "Deleted Successfully")
menu()

Page | 26
else:
menu()

def members_details():
print("1.Add Member")
print("2.Display Members")
print("3.Search Member")
print("4.Update Member Details")
print("5.Delete Member Details")
print("6.Return To Main Menu")
ch=int(input("Enter your choice:"))
if(ch==1):
add_member()
elif(ch==2):
disp_members()
elif(ch==3):
x=int(input("Enter the Member ID"))
search(x)
menu()
elif(ch==4):
upd_member()
elif(ch==5):
del_member()
elif(ch==6):

Page | 27
menu()

def issue_book():
s='unavailable'
bid=int(input("Enter the book ID"))
d=searchbook_id(bid)
print(d)
print(d[5])
if d[5]=='available':
mid=int(input("Enter the member ID"))
t_date = datetime.date.today()
m=search(mid)
print(m)
query1="insert into issue_return values({},
{},'{}',null)".format(bid,mid,t_date)
query2="update books set Status='{}' where
BNo={}".format(s,bid)
cur.execute(query1)
cur.execute(query2)
con.commit()
print("Book issued ")
menu()
else:
print("sorry book unavailable")

Page | 28
menu()

def return_book():
s='available'
t_date=datetime.date.today()
sql="select*from issue_return"
cur.execute(sql)
rec=cur.fetchall()
bid=int(input("Enter the book ID"))
mid=int(input("Enter the member ID"))
for i in rec:
if i[0]==bid and i[1]==mid:
query1="update issue_return set return_date='{}' where
bid={} and mid={}".format(t_date,bid,mid)
query2="update books set status='{}' where
BNo={}".format(s,bid)
cur.execute(query1)
cur.execute(query2)
con.commit()
print("Book Returned")
menu()
else:
menu()

Page | 29
def issue_status():
query="select
books.bname,members.name,issue_return.issue_date,issue_return.retu
rn_date from books,members,issue_return where
(books.bno=issue_return.bid) and (members.mno=issue_return.mid)"
cur=con.cursor()
cur.execute(query)
data=cur.fetchall()
print("********Library Management
system********************")

print("***************************************************
*************")
print("Book Name Member Name Issue_date Return_date")
for i in data:
print(i[0],'\t',i[1],'\t',i[2],'\t',i[3])
menu()

def menu():
print("###########################################")
print("Library Management System ")
print("MAIN MENU")
print("###########################################")
print("1.Book Details ")

Page | 30
print("2.Membership details")
print("3.issue book")
print("4.return book")
print("5.Display Book Issue status")
print("6.Exit")
ch=int(input("Enter Your Choice(INTEGER): "))
if(ch==1):
bookdetails()
elif(ch==2):
membersdetails()
elif(ch==3):
issue_book()
elif(ch==4):
return_book()
elif(ch==5):
issue_status()
elif(ch==6):
quit()
menu()

Page | 31
OUTPUT
1 . MAIN MENU :

2.
BOOK MANAGEMENT :

3 . ADDING A BOOK :

Page | 32
4 . DISPLAYING THE BOOKS :

BIBLIOGRAPHY
Page | 33
 TEXTBOOKS :
1. Computer Science with Python – Sumitha Arora
2. Computer Science Class 12 – Arihant Publications

 WEBSITES :
1. https://www.tutorialsteacher.com/python/
2. www.cbseprojectguide.com
3. www.stackedoverflow.com
4. www.python4csip.com

Page | 34

You might also like