Computer Project Final
Computer Project Final
Haryana
Computer Science Project
Library Management System
Submitted by: -
Name: - Arshbir Singh Dang
Class: - XII A
Roll No: -
Index
Topic Page
Certificate 1
Acknowledgement 2
System Requirements 3
Introduction 4
Assumptions 5
Output 18
Certificate
It is herby to certify that, the original and genuine
investigation work has been carried out to investigate about
the subject matter and related data collection investigation
has been completed solely, sincerely, and satisfactorily done
by Arshbir Singh Dang of class XI-A, Apeejay School Faridabad,
Haryana regarding the project titled, “Library Management”.
Submitted for ALL India SENIOR SECONDARY EXAMINATION
held on ____________ at Apeejay School Sector-15 Faridabad,
Haryana.
Acknowledgement
The successful completion of any task would be
incomplete without mentioning the names of those
person who helped to make it possible. I take this
opportunity to express my gratitude in few words and
respect to all those who help me in the completion of
the project it is humble pleasure to acknowledge me
deep senses gratitude to my computer science teacher,
Mrs Shalini Yadav for her valuable support, constant
help and guidance at each and every stage without
which this project would not have come forth. I also
register my sense of gratitude to our principal, Dr Parul
Tyagi, for her immense encouragement that has made
this project successful. I would like also to thank my
friends and family for encouraging during the course of
this project. Last but not least I would like to thank CBSE
for giving us the opportunity to undertake this project.
System Requirements of the Project
Recommended System Requirements
Processors: Intel® Core™ i3 processor 4300M at 2.60 GHz.
Disk space: 2 to 4 GB.
Operating systems: Windows® 10, MACOS, and UBUNTU.
Python Versions: 3.X.X or Higher.
Minimum System Requirements
Processors: Intel Atom® processor or Intel® Core™ i3 processor.
Disk space: 1 GB.
Operating systems: Windows 7 or later, MACOS, and UBUNTU.
Python Versions: 2.7.X, 3.6.X.
You need root or administrator privileges to perform the installation
process.
Python must be installed on your machine.
Introduction
A college library management is a project that manages and
stores books information electronically according to students
needs. The system helps both students and library manager to
keep a constant track of all the books available in the library. It
allows both the admin and the student to search for the
desired book. It becomes necessary for colleges to keep a
continuous check on the books issued and returned and even
calculate fine. This task if carried out manually will be tedious
and includes chances of mistakes. These errors are avoided by
allowing the system to keep track of information such as issue
date, last date to return the book and even fine information
and thus there is no need to keep manual track of this
information which thereby avoids chances of mistakes.
Thus this system reduces manual work to a great extent allows
smooth flow of library activities by removing chances of errors
in the details.
Assumptions
1. Any library member should be able to search books by their title, author,
subject category as well by the publication date.
2. Each book will have a unique identification number and other details
including a rack number which will help to physically locate the book.
3. There could be more than one copy of a book, and library members
should be able to check-out and reserve any copy. We will call each copy
of a book, a book item.
4. The system should be able to retrieve information like who took a
particular book or what are the books checked-out by a specific library
member.
5. There should be a maximum limit (5) on how many books a member can
check-out.
6. There should be a maximum limit (10) on how many days a member can
keep a book.
7. The system should be able to collect fines for books returned after the
due date.
8. Members should be able to reserve books that are not currently available.
9. The system should be able to send notifications whenever the reserved
books become available, as well as when the book is not returned within
the due date.
10. Each book and member card will have a unique barcode. The system will
be able to read barcodes from books and members’ library cards.
SOURCE CODE
def command(st):
cursor.execute(st)
def fetch():
data = cursor.fetchall()
for i in data:
print(i)
def all_data(tname):
li = []
st = 'desc '+tname
command(st)
data = cursor.fetchall()
for i in data:
li.append(i[0])
st = 'select * from '+tname
command(st)
print('\n')
print('-------ALL_DATA_FROM_TABLE_'+tname+'_ARE-------\n')
print(tuple(li))
fetch()
def detail_burrower(name,contact):
tup=('SN','borrowers_name','book_lent','date','contact_no')
print('\n---Details for borrower '+name+'---\n')
print(tup)
st='select * from borrower where borrowers_name like "{}" and
contact_no={}'.format(name,contact)
command(st)
fetch()
def days_between(d1, d2):
d1 = datetime.strptime(d1, "%Y-%m-%d")
d2 = datetime.strptime(d2, "%Y-%m-%d")
global days
days=abs((d2 - d1).days)
def price_book(days,book_name):
st1 = 'select Price_Per_Day from books where
Book_Name="{}"'.format(book_name)
command(st1)
data = cursor.fetchall()
for i in data:
global t_price
t_price=int(i[0])*days
print('No. of days {} book is kept : {}'.format(book_name,days))
print('Price per day for book {} is Rs.{}'.format(book_name,i[0]))
print('Total fare for book '+book_name +'-',t_price)
def lend():
flag='True'
while flag=='True':
print('\n___AVAILABLE BOOKS___\n')
st0 = 'select Book_Name from books where
Quantity_Available>=1'
command(st0)
fetch()
st1='select max(SN) from borrower'
command(st1)
data_sn=cursor.fetchall()
for i in data_sn:
SN=i[0]+1
book_selected=str(input('Enter name of book from above list : '))
borrowers_name=str(input('Enter Borrower Name : '))
date=str(input('Enter date (YYYY-MM-DD) : '))
contact=int(input('Enter contact no. : '))
st_insert='insert into borrower values({},"{}","{}","{}",
{})'.format(SN,borrowers_name,book_selected,date,contact)
command(st_insert)
st_quantity='select quantity_available from books where
book_name="{}"'.format(book_selected)
command(st_quantity)
data_quantity=cursor.fetchall()
for quantity in data_quantity:
qty=quantity[0]-1
st_dec='update books set quantity_available={} where
book_name="{}"'.format(qty,book_selected)
command(st_dec)
dec=str(input('Do you want to add more records (Y/N) : '))
if dec.upper=="Y":
flag= 'True'
else:
flag='False'
def borrowers():
print('\n\n___OPTIONS AVAILABLE___\n\nEnter 1 : To Show detail
of all borrowers \nEnter 2 : To check detail of a particular borrower \
nEnter 3 : To calculate total fine of a borrower \nEnter 4 : To go Back \
nEnter 5 : To commit all the changes and exit')
dec = input('enter your choice-')
if dec=='1':
all_data('borrower')
elif dec=='2':
name = str(input('\nenter borrower name-'))
contact = str(input('enter borrower contact no.-'))
detail_burrower(name,contact)
elif dec=='3':
tfine()
elif dec=='4':
action_list()
elif dec=='5':
close()
borrowers()
def tfine():
name=str(input('\nEnter borrower name : '))
contact=input('Enter borrower contact_no : ')
detail_burrower(name, contact)
st1 = 'select book_lent from borrower where borrowers_name ="{}"
and contact_no={}'.format(name,contact)
command(st1)
data=cursor.fetchall()
for i in data:
book_name=i[0]
st2 = 'select date from borrower where borrowers_name="{}" and
book_lent="{}"'.format(name,book_name)
command(st2)
data1=cursor.fetchall()
for date in data1:
date_taken=date[0]
date_return = str(input('\nEnter returning date for book "{}"
(YYYY-MM-DD) , Press ENTER to skip-'.format(book_name)))
while date_return!='':
days_between(str(date_return),str(date_taken))
price_book(days,i[0])
print('\nEnter Y : If Rs.{} is paid and book is returned.\nEnter
N : If fare is not paid and book is not returned.'.format(t_price))
dec=str(input('Enter (Y?N) : '))
if dec.upper()=="Y":
st= 'select SN , Quantity_Available from books where
Book_Name ="{}"'.format(i[0])
command(st)
data2=cursor.fetchall()
for price in data2:
update('books', 'Quantity_Available',price[1]+1,price[0])
st_del = 'delete from borrower where
borrowers_name="{}" and book_lent="{}"'.format(name,book_name)
command(st_del)
break
else:
print("\n\nPLEASE PAY THE FARE AND RETURN BOOK
AFTER READING.\n\n")
break
def insert():
flag = 'true'
while flag=='true':
licol=[]
li1=[]
li_val=[]
command('desc books')
data=cursor.fetchall()
for i in data:
licol.append(i[0])
command('select max(SN) from books')
dta=cursor.fetchall()
for j in dta:
li_val.append(j[0]+1)
for k in range(1,4):
val = str(input('Enter '+licol[k]+'-'))
li_val.append(val)
li1.append(tuple(li_val))
values = ', '.join(map(str, li1))
st1 = "INSERT INTO books VALUES {}".format(values)
command(st1)
all_data('books')
print('\n')
print("\nDATA INSERTED SUCCESSFULLY\n")
dec = str(input('Do u want to insert more data?(Y/N)-'))
if dec.upper() == "Y":
flag='true'
else:
flag='false'
action_list()
def update(tname,col1,post_value,pre_value):
st = str('update %s set %s=%s where SN=%s') % (tname, col1, "'%s'",
"'%s'") % (post_value, pre_value)
command(st)
all_data(tname)
print('\nVALUE UPDATED SUCCESSFULLY')
def close():
mycon.commit()
mycon.close()
if mycon.is_connected():
print('still connected to localhost')
else:
print('\n\nconnection closed successfully.')
sys.exit()
def action_list():
print('\n')
print('#### WELCOME TO LIBRARY MANAGEMENT SYSTEM ####\n\
nEnter 1 : To View details of all available Books\nEnter 2 : To check
detail of a particular book\nEnter 3 : To lend a book \nEnter 4 : To add
new books in list \nEnter 5 : To update data \nEnter 6 : To view details
of borrowers \nEnter 7 : To commit all changes and exit')
dec = input('\nenter your choice-')
if dec == '1':
all_data('books')
elif dec=='2':
tup=('SN','Book_Name','Quantity_Available','Price_Per_Day')
tup1 = ('SN', 'borrowers_name', 'book_lent', 'contact_no')
in1=str(input('enter first name , last name or middle name of a
book-'))
print('\n___ALL DATA OF BOOKS HAVING "{}" IN THEIR NAME
FROM BOTH TABLE____'.format(in1))
st =str('select * from books where book_name like
"{}"'.format('%'+in1+'%'))
st1=str('select * from borrower where book_lent like
"{}"'.format('%'+in1+'%'))
print('\n__DATA FROM TABLE BOOKS__\n')
command(st)
print(tup)
fetch()
print('\n__DATA FROM TABLE BORROWER__\n')
command(st1)
print(tup1)
fetch()
print()
elif dec == '3':
lend()
elif dec=='4':
insert()
elif dec=='5':
flag='true'
while flag=='true':
tname = 'books'
li = []
st1 = 'desc '+tname
command(st1)
data = cursor.fetchall()
for i in data:
li.append(i[0])
all_data(tname)
print('\n columns in table '+tname+' are')
print(li)
col1 = str(input('enter column name for modification from
above list-'))
lipo = ['SN']
lipo.append(col1)
print(tuple(lipo))
st0 = 'select SN , %s from books' % (col1)
command(st0)
fetch()
pre_value = str(input('enter corresponding SN for the data to
be changed-'))
post_value = str(input('enter new value for column %s having
SN %s-' % (col1, pre_value)))
update(tname, col1, post_value, pre_value)
dec = str(input('Do you want to change more data?(Y/N)-'))
if dec == 'y' or dec == 'Y':
flag='true'
else:
flag='false'
elif dec=='6':
borrowers()
elif dec=='7':
close()
action_list()
action_list()
Output