0% found this document useful (0 votes)
5 views

Computer Science Project Sumit

Uploaded by

bhattsumit504
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Computer Science Project Sumit

Uploaded by

bhattsumit504
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

COMPUTER SCIENCE PROJECT

ON
LIBRARY MANAGEMENT

SUBMITTED BY-
NAME- SUMIT BHATT
CLASS- XII-A
ROLL NO-
SUBJECT- Computer Science
SESSION- 2024-25
ACKNOWLEDGEMENT
I wish to express my deep gratitude and sincere thanks to our
school management for their encouragement and for all the
facilities they provided for this project work. I sincerely
appreciate this magnanimity.
I extend my hearty thanks to Mrs. Preeti Tandon, my computer
science teacher, who guided me to the successful completion of
this project. I take this opportunity to express my deep sense of
gratitude for her invaluable guidance, constant encouragement,
constructive comments, sympathetic attitude and immense
motivation, which has sustained my efforts at all stages of this
project work.
I can’t forget to offer my sincere thanks to my classmates who
helped me to carry out this work successfully and for their
valuable advice and support, which I received from them time to
time.

NAME- SUMIT BHATT


CERTIFICATE
This is to certify that the project titled, “LIBRARY MANAGEMENT”
is a piece of work done by Sumit Bhatt of class XII A session 2024-
25 in partial fulfilment of the requirement of CBSE , Delhi.
The project work reported here is as per the guidelines of CBSE
for AISSCE practical examination and it is done under the
supervision of Mrs. Preeti Tandon . The project work ,carried out
by him is not a form of any other project work.

______________
Signature of Teacher
Mrs. PREETI TANDON
CONTENTS

SR.NO TOPIC NAME


1 INTRODUCTION
2 DATABASE TABLE
3 SOURCE CODE
4 OUTPUT
5 CONCLUSION
6 BIBLIOGRAPHY
INTRODUCTION
The library management system is basically a
database based project done with help of python
language. This project is very useful for the
librarians to keep a count on what project they
have and how much they sold or issued books.
This project is multi-field project, so that it can
be modified for various purpose.
DATABASE TABLE
DATABASE: LIBRARY

TABLE 1: USER
TABLE 2: BOOKS

TABLE 3: MEMBERS
TABLE 4: BOOKS_ISSUED
SOURCE CODE
import mysql.connector as msql
mydb=msql.connect(host='localhost',user='root',password='legacy',
database='library')
def addNewBook():
bookid=input('ENTER BOOK ID:')
title=input('ENTER BOOK TITLE:')
author=input('ENTER AUTHOR OF THE BOOK:')
publisher=input('ENTER BOOK PUBLISHER:')
quantity=input('ENTER NUMBER OF BOOKS:')
cost=input('ENTER THE COST OF THE BOOK:')
q="insert into books values(%s,%s,%s,%s,%s,%s)"
data=(bookid,title,author,publisher,quantity,cost)
cr=mydb.cursor()
cr.execute(q,data)
print('\nBOOK INSERTED !!!')
mydb.commit()
def searchBook():
bookid=input('ENTER BOOK ID:')
q='select * from books where book_id='+bookid
cr=mydb.cursor()
cr.execute(q)
res=cr.fetchone()
if res== None:
print('No book with this id')
else:
print('|BOOK ID|\t
|TITLE|\t\t|AUTHOR|\t\t|PUBLISHER|\t|QUANTITY|\t|COST|')
print(res[0],'\t\t',res[1],'\t',res[2],'\t\t',res[3],'\t ',res[4],'\t
',res[5])
def deleteBook():
bookid=input('ENTER BOOK ID:')
q='delete from books where book_id='+bookid
cr=mydb.cursor()
cr.execute(q)
print('BOOK DELETED!!!')
mydb.commit()
def showBooks():
q='select * from books'
cr=mydb.cursor()
cr.execute(q)
res=cr.fetchall()
print('|BOOK_ID|\t\t|TITLE|\t\t|AUTHOR|\t\t|PUBLISHER|\t\t|QUANTI
T
Y|\t|COST|')
for i in res:
print(i[0],'\t\t',i[1],'\t',i[2],'\t\t',i[3],'\t\t',i[4],'\t\t',i[5])
def addNewMember():
mid=input('ENTER MEMBER ID:')
mname=input('ENTER MEMBER NAME:')
phoneno=input('ENTER PHONE NUMBER:')
number_of_book_issued=0
q='insert into members values(%s,%s,%s,%s)'
data=(mid,mname,phoneno,number_of_book_issued)
cr=mydb.cursor()
cr.execute(q,data)
print('\nMEMBER ADDED!!!')
mydb.commit()
def searchMember():
mid=input('ENTER MEMBER ID:')
q='select * from members where member_id='+mid
cr=mydb.cursor()
cr.execute(q)
res=cr.fetchone()
if res== None:
print('No member with this id')
else:
print('|MEMBER ID|\t|NAME|\t\t|PHONE NO.|\t|NUMBER OF
BOOKS ISSUED|')
print(res[0],'\t\t',res[1],'\t',res[2],'\t\t',res[3])

def deleteMember():
mid=input('ENTER MEMBER ID:')
q='delete from members where member_id='+mid
cr=mydb.cursor()
cr.execute(q)
print('MEMBER DELETED!!!')
mydb.commit()
def showMembers():
q='select * from members'
cr=mydb.cursor()
cr.execute(q)
res=cr.fetchall()
print('|MEMBER_ID|\t|NAME|\t\t|PHONE_NO|\t\t|NUMBER OF
BOOK ISSUED|')
for i in res:
print(i[0],'\t\t',i[1],' ',i[2],' \t ',i[3])
def issueBooks():
issueID=input('ENTER ISSUE ID:')
bid=input('ENTER BOOK ID:')
bname=input('ENTER BOOK NAME:')
mid=input('ENTER MEMBER ID:')
mname=input('ENTER MEMBER NAME:')
date_of_issue=input('enter date (yyyy-mm-dd):')
q='insert into books_issued values(%s,%s,%s,%s,%s,%s,NULL)'
data=(issueID,bid,bname,mid,mname,date_of_issue)
cr=mydb.cursor()
cr.execute(q,data)
mydb.commit()
print('BOOK ISSUED TO:',mname)
updateBook(bid,-1)
updateMembers(mid,1)

def updateBook(bid,u):
q='select quantity from books where book_id=%s'
data=(bid,)
cr=mydb.cursor()
myresult=cr.fetchone()
t=myresult[0]+u
sql='update books set quantity=%s where book_id=%s'
d=(t,bid)
cr.execute(sql,d)
mydb.commit()
def updateMembers(mid,z):
q='select number_of_book_issued from members where
member_id=%s'
data=(mid,)
cr=mydb.cursor()
cr.execute(q,data)
myresult=cr.fetchone()
t=myresult[0]+z
sql='update members set number_of_book_issued=%s where
member_id=%s'
d=(t,mid)
cr.execute(sql,d)
mydb.commit()
def returnBook():
issueid=input('ENTER ISSUE ID:')
returndate=input('ENTER DATE OF RETURN(YYYY-MM-DD):')
q='update books_issued set date_of_return=%s where issue_id=%s'
data=(returndate,issueid)
cr=mydb.cursor()
cr.execute(q,data)
mydb.commit()
print('RECORD ADDED!!!')
def showIssued_Books():
q='select * from books_issued'
cr=mydb.cursor()
cr.execute(q)
res=cr.fetchall()
print('|ISSUE ID|\t|BOOK ID|\t|BOOK NAME|\t|MEMBER
ID|\t|MEMBER NAME|\t|DATE OF ISSUE|\t|DATE OF RETURN|')
for i in res:
print(i[0],'\t\t',i[1],'\t\t',i[2],'\t',i[3],'\t\t',i[4],'\t',i[5],'\t\t',i[6])
def deleteIssued_Books():
issueid=input('ENTER ISSUE ID:')
q='delete from books_issued where issue_id='+issueid
cr=mydb.cursor()
cr.execute(q)
print('RECORD DELETED!!!')
mydb.commit()
if mydb.is_connected():
print("Connected...")
uname =input("Enter Username : ")
passw = input("Enter Password : ")
q = "select * from user where username = %s and password = %s"
d =(uname,passw)
cr =mydb.cursor()
cr.execute(q,d)
res = cr.fetchone()
if res == None:
print("Invalid Username or Password")
else:
print("-" * 30)
print("Access Granted, Welcome !!!")
while True:
print('-'*70)
print('\t\t\tNATIONAL DIGITAL LIBRARY')
print('-'*70)
print('PRESS 1- TO ADD A BOOK')
print('PRESS 2- TO SEARCH A BOOK')
print('PRESS 3- TO DELETE BOOK')
print('PRESS 4- TO SHOW ALL BOOK')
print('PRESS 5- TO ADD NEW MEMBER')
print('PRESS 6- TO SEARCH MEMBER')
print('PRESS 7- TO DELETE A MEMBER')
print('PRESS 8- TO SHOW ALL MEMBERS')
print('PRESS 9- TO ISSUE BOOK')
print('PRESS 10- TO RETURN BOOK')
print('PRESS 11- TO SHOW ISSUED BOOKS')
print('PRESS 12- TO DELETE ISSUED BOOKS')
print('PRESS 13- TO EXIT')
print('-'*70)
ch=int(input('ENTER YOUR CHOICE:'))
if ch==1:
addNewBook()
elif ch==2:
searchBook()
elif ch==3:
deleteBook()
elif ch==4:
showBooks()
elif ch==5:
addNewMember()
elif ch==6:
searchMember()
elif ch==7:
deleteMember()
elif ch==8:
showMembers()
elif ch==9:
issueBooks()
elif ch==10:
returnBook()
elif ch==11:
showIssued_Books()
elif ch==12:
deleteIssued_Books()
elif ch==13:
print('EXITTING............')
break
else:
print('INVALID INPUT')
print('THANK YOU FOR VISITING THE LIBRARY')
OUTPUT
TO ADD A NEW BOOK

TO SEARCH A BOOK
TO DELETE A BOOK
TO SHOW ALL BOOKS

TO ADD NEW MEMBER


TO SEARCH MEMBER

TO DELETE A MEMBER

TO SHOW ALL MEMBERS


TO ISSUE BOOK

TO RETURN BOOK
TO SHOW ISSUED BOOKS

TO DELETE ISSUED BOOKS


EXIT
CONCLUSION
Library management has been prepared to
reduce the manual work and with the help
of this project every work is been processed
through python and MYSQL.

This project is developed and designed to


achieve maximum. Efficiency and reduces
the time taken to handle the management
and issuing activity. It also reduces the time
taken storing data.
BIBLIOGRAPHY

• Computer science with python book


(SUMITA ARORA)
• Computer science with python book
(PREETI ARORA)
• www.geeksforgeeks.org

You might also like