Cs Project

You might also like

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

LIBRARY MANAGEMENT SYSTEM

SESSION:2021-2022
CLASS-12

MADE BY-
INDEX

1. CERTIFICATE…………………………………………………………...3

2. ACKNOWLEDGEMENT………………………………………………...4

3. INTRODUCTION………………………………………………………...5

4. FEATURES……………………………………………………………….6

5. VALIDATION AND CHECKS…………………………………………..7

6. HARDWARE AND SOFTWARE REQUIREMENTS…………………..8

7. PROJECT FLOW DIAGRAM……………………………………………9

8. PROJECT FLOW DETAIL……………………………………………….10

9. PROGRAM CODING…………………………………………………….11-20

10. INPUT AND OUTPUT DESIGNS.………………………………………..21-29

11.BIBLIOGRAPHY…………………………………………………………30
CERTIFICATE

This is to certify that this is a bonafide record of the project work done
satisfactorily at _______________________________________________
by_______________ of class XII, on the topic Library Management System
in Python.

All the modules have been successfully completed by him. The project has been
submitted in hard and soft copy in working condition with all the required
documents.

Project guide

(____________________)

Signature:
ACKNOWLEDGEMENT

I would like to thank _____________________ for his courtesy to give his


precious time to guide me through the project.

Student Name:

Board Roll No:

Class & Sec:

Student Signature:

Dated:
INTRODUCTION

 This software project is a library management software system with all


the basic as well as some innovative features for managing a library.

 It consists of a large database of various books available in the library. It


also lists various books issued to respective readers.

 The system keeps track of all the books readily available and the books
that have been issued to various readers for the time period for which the
books have been issued.

 The system also handles books database.

 Readers usually tend to forget the date to return their library books, so
this system even calculates fine depending on the expiry date.

 Thus, this library management system provides enhanced library


functionality for this modern world.
FEATURES

 It is a menu driven programme.

 A lot of time, paper and human efforts are saved as the data is managed
electronically.

 There is no need for the manual records to be kept.

 It also calculates the fine charged to the user due to late return of a book.

 The information of new arrival of books in library and their availability


can be updated in the system by the admin.
VALIDATION AND CHECKS

Whenever an issue is made, the name of the book issued and the date of issue
is saved on the system under the user name/ID.

Readers usually tend to forget the date to return their library books.

After entering name/ID of the user, the system first checks if an issue has been
made and the date of issue.

Then it checks the date expiry date.

It calculates fine depending on the expiry date.

Once the fine has been paid and the book has been turned the due amount
returns to zero.
HARDWARE AND SOFTWARE REQUIREMENTS

Software Links:

 Download Link Python: https://www.python.org/


 Download Link for MySQL Server:
https://dev.mysql.com/downloads/mysql/
 Download Link for SQLite: https://www.sqlite.org/download.html

Minimum System Requirements:

 Processors: Intel® Core™ i3 processor or above


 Disk space: 1 GB or above
 Operating systems: Windows 8 or above
 Python: Version 3.7.4 or above
 MySQL Server: Version 5.1 or above

OR

 SQLite version 3.36.0 or above


PROJECT FLOW DIAGRAM

Book request Check


No if any fine is Check
No if the book Book reserved
Enter User ID due is available for the user

Book return Yes

Amount of fine to Book issued to


be paid the user for a
week

After
Payment
Update on the
system
PROJECT FLOW DETAIL

 First the used Id is entered into the database.

 After the request of a book the system first checks if there are any dues
left or if a book is to be returned.

 If yes, then the fine is calculated by the system on the basis of the expiry
date.

 After the payment is done the system is updated and the due returns back
to zero.

 After the dues are cleared the request of book is processed.

 The system checks whether the book is available for issue or not.
 If yes, then the book is issued to the user for a week and it is updated on
the system.

 If the book is not available, then it is reserved by the system for the user.

PROGRAM CODING
import mysql.connector
from datetime import date
mydb = mysql.connector.connect(host='localhost', database='library1',
user='root', password='0604')

def add_book():

title = input('Enter Book Title :')


author = input('Enter Book Author : ')
pages = int(input('Enter Book Pages : '))
price = input('Enter Book Price : ')
copies = int(input('Enter copies : '))
book_id=input('Enter Book id')
data = (title, author, pages, price, copies, book_id)
sql = 'insert into book values(%s,%s,%s,%s,%s,%s)'
cursor = mydb.cursor()
cursor.execute(sql,data)
mydb.commit()
print('\n\nNew Book added successfully')
main_menu()

def add_member():

name = input('Enter Member Name :')


phone = input('Enter Member Phone : ')
mem_id=input('Enter Member id:')
data=(name, phone,mem_id)
sql = 'insert into member values(%s,%s,%s)'
cursor = mydb.cursor()
cursor.execute(sql,data)
mydb.commit()
print('\n\nNew Member added successfully')
main_menu()

def modify_book():

print('Modify BOOK Details Screen ')


print('-'*120)
print('\n1. Book Title')
print('\n2. Book Author')
print('\n3. Book Pages')
print('\n4. Book Price')
print('\n\n')
choice = int(input('Enter your choice :'))
field = ''
if choice == 1:
field = 'title'
if choice == 2:
field = 'author'
if choice == 3:
field = 'pages'
if choice == 4:
field = 'price'
book_id = input('Enter Book ID :')
value = input('Enter new value :')
if field =='pages' or field == 'price':
sql = 'update book set ' + field + ' = '+value+' where book_id =
'+book_id+';'
else:
sql = 'update book set ' + field + ' = "'+value+'" where book_id =
'+book_id+';'
cursor = mydb.cursor()
cursor.execute(sql)
mydb.commit()
print('\n\n\nBook details Updated.....')
main_menu()

def modify_member():

print('Modify Memeber Information Screen ')


print('-'*120)
print('\n1. Name')
print('\n2. Phone')
print('\n\n')
choice = int(input('Enter your choice :'))
field =''
if choice == 1:
field ='name'
if choice == 2:
field = 'phone'
mem_id =input('Enter member ID :')
value = input('Enter new value :')
sql = 'update member set '+ field +' = "'+value+'" where mem_id =
'+mem_id+';'
cursor = mydb.cursor()
cursor.execute(sql)
mydb.commit()
print('Member details Updated.....')
main_menu()

def mem_issue_status(mem_id):
sql ='select * from transaction where mem_id ='+mem_id +' and date_return
is NULL;'
cursor = mydb.cursor()
cursor.execute(sql)
results = cursor.fetchall()
return results

def book_status(book_id):
sql = 'select * from book where book_id ='+book_id + ';'
cursor = mydb.cursor()
cursor.execute(sql)
result = cursor.fetchone()
return result[4]
def book_issue_status(book_id,mem_id):
sql = 'select * from transaction where book_id ='+book_id + ' and mem_id
='+ mem_id +' and date_return is NULL;'
cursor = mydb.cursor()
cursor.execute(sql)
result = cursor.fetchone()
return result

def issue_book():

print('\n BOOK ISSUE SCREEN ')


print('-'*120)
book_id = input('Enter Book ID : ')
mem_id = input('Enter Member ID :')
result = book_status(book_id)
result1 = mem_issue_status(mem_id)
today = date.today()
if len(result1) == 0:
if result == 'available':
data=(book_id, mem_id, date_issue)
sql = 'insert into transaction values(s%,s%,s%);'
sql_book = 'update book set status="issue" where book_id ='+book_id +
';'
cursor = mydb.cursor()
cursor.execute(sql,data)
cursor.execute(sql_book)
print('\n\n\n Book issued successfully')
else:
print('\n\nBook is not available for ISSUE... Current status :',result1)
else:
if len(result1)<1:
data= (book_id, mem_id, date_issue)
sql = 'insert into transaction) values(s%,s%,s%);'
sql_book = 'update book set status="issue" where book_id ='+book_id + ';'
cursor = mydb.cursor()
cursor.execute(sql,data)
cursor.execute(sql_book)
mydb.commit()
print('\n\n\n Book issued successfully')
else:
print('\n\nMember already have book from the Library')
main_menu()

def return_book():
global fine_per_day
print('\n BOOK RETURN SCREEN ')
print('-'*120)
book_id = input('Enter Book ID : ')
mem_id = input('Enter Member ID :')
today =date.today()
result = book_issue_status(book_id,mem_id)
if result==None:
print('Book was not issued...Check Book Id and Member ID again..')
else:
sql='update book set status ="available" where book_id ='+book_id +';'
din = (today - result[3]).days
fine = din * fine_per_day
sql1 = 'update transaction set date_return ="'+str(today)+'" , fine='+str(fine)
+' where book_id='+book_id +' and mem_id='+mem_id+' and date_return is
NULL;'
cursor = mydb.cursor()
cursor.execute(sql)
cursor.execute(sql1)
mydb.commit()
print('\n\nBook returned successfully')
main_menu()

def search_book(field):
print('\n BOOK SEARCH SCREEN ')
print('-'*120)
msg ='Enter '+ field +' Value :'
title = input(msg)
sql ='select * from book where '+ field + ' like "%'+ title+'%"'
cursor = mydb.cursor()
cursor.execute(sql)
records = cursor.fetchall()

print('Search Result for :',field,' :' ,title)


print('-'*120)
for record in records:
print(record)
mydb.commit()
main_menu()

def search_menu():
while True:
print(' S E A R C H M E N U ')
print("\n1. Book Title")
print('\n2. Book Author')
print('\n3. Exit to main Menu')
print('\n\n')
choice = int(input('Enter your choice ...: '))
field =''
if choice == 1:
field='title'
if choice == 2:
field = 'author'
if choice == 3:
break
search_book(field)

def change_book_status(status,book_id):
mydb = mysql.connector.connect(host='localhost', database='library',
user='root', password='')
cursor = mydb.cursor()
sql = 'update book set status = "'+status +'" where id ='+book_id + ' and status
="available"'
cursor.execute(sql)
print('Book status changed to ',status)
print('\n\n\n')
mydb.commit()
main_menu()

def main_menu():

print('L I B R A R Y M E N U')
print("\n1. Add Books")
print('\n2. Add Member')
print('\n3. Modify Book Information')
print('\n4. Modify Student Information')
print('\n5. Issue Book')
print('\n6. Return Book')
print('\n7. Search Menu')
print('\n\n')
choice = int(input('Enter your choice ...: '))
if choice == 1:
add_book()
if choice == 2:
add_member()
if choice == 3:
modify_book()
if choice == 4:
modify_member()
if choice == 5:
issue_book()
if choice == 6:
return_book()
if choice == 7:
search_menu()
else:
print("Wrong choice...")

def passwd():
ps=input("Enter password:")
if ps=="0604":
main_menu()
else:
print("Wrong password")
passwd()
passwd()

INPUT AND OUTPUT DESIGNS


\
BIBLIOGRAPHY

Online Sources:

 https://www.python.org/
 https://www.youtube.com/codepython

Reference Books:

 Computer Science with Python by Preeti Arora


 Computer Science with Python by Sumita Arora

You might also like