Professional Documents
Culture Documents
Cs Project
Cs Project
Cs Project
SESSION:2021-2022
CLASS-12
MADE BY-
INDEX
1. CERTIFICATE…………………………………………………………...3
2. ACKNOWLEDGEMENT………………………………………………...4
3. INTRODUCTION………………………………………………………...5
4. FEATURES……………………………………………………………….6
9. PROGRAM CODING…………………………………………………….11-20
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
Student Name:
Student Signature:
Dated:
INTRODUCTION
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.
Readers usually tend to forget the date to return their library books, so
this system even calculates fine depending on the expiry date.
A lot of time, paper and human efforts are saved as the data is managed
electronically.
It also calculates the fine charged to the user due to late return of a book.
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.
Once the fine has been paid and the book has been turned the due amount
returns to zero.
HARDWARE AND SOFTWARE REQUIREMENTS
Software Links:
OR
After
Payment
Update on the
system
PROJECT FLOW DETAIL
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.
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():
def add_member():
def modify_book():
def modify_member():
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():
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()
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()
Online Sources:
https://www.python.org/
https://www.youtube.com/codepython
Reference Books: