CS Class 12 Project
CS Class 12 Project
CS Class 12 Project
SYSTEM
A PROJECT REPORT
SUBMITTED TO
NATIONAL MODEL SENIOR SECONDARY SCHOOL
AFFILIATED TO CBSE FOR THE AISSCE 2023
BY
VARUN S
NATIONAL MODEL
SENIOR SECONDARY SCHOOL
JANUARY
2023
Page | 1
CERTIFICATE
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.
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.
Page | 4
TABLE OF CONTENTS
Overview
1. Project Synopsis 8
2. Requirements 10
Page | 5
OVERVIEW
Python Features :
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 :
Page | 7
PROJECT SYNOPSIS
3. Search Menu
Page | 8
4. Issue and Return
5. Membership Details
1. Using book id
2. Using book type
3. Using author name
4. Using book name
Page | 9
Page | 10
REQUIREMENTS
Keyboard : USB
Mouse : USB
SOFTWARE REQUIRED :
Operating system : Windows 8 or above
Python IDLE : 3.6 or above
Page | 11
BACK END DETAILS
Page | 12
PACKAGES & FUNCTIONS USED IN
THE PROJECT
PACKAGE / MODULE
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