Library Management System: Project On
Library Management System: Project On
DATE:
Internal Examiner:
Name:
ROLL NO:
Acknowledgement
In the accomplishment of this project successfully, many People have best owned upon me their
blessings and the heart pledged support. This time I am utilizing to thank all the people who have
been concerned with this project.
Then I would like to thank my parents and friends who have helped me with their valuable
suggestions. Their guidance has been very helpful in various phases of completion of project.
Last but not the least I would like to thank my classmates who have helped me a lot.
INDEX
I. Brief Overview of Project
VII. Flowchart
X. Output Screen
XI. Bibliography
Brief Overview of the Project
The main objective of this python project is to assist libraries in
managing details of their members, borrowed books, member
dues and several other details. The system revolves around the
day-to-day activities of a librarian of any large library where
members are allowed to borrow books.
The aim of this project is hence to reduce the manual work done
by a librarian and automate most of the processes. This is done
with the help of a database connected to a python CLI
(command line interface) to enter data and persistently store
them. Several features like the ability to add and remove books ,
issuing and registering returns of books , maintaining details
regarding member dues and late fines etc.
Apart from the typical benefits that come with any computerized
version of a manual management process, there are several
other side benefits as well. For example , a computerized system
is environmentally friendly and saves an organization several
rolls of paper.
Available Features
The library management system described in this project is
capable of the following tasks:
Database Structure
Books
Field type
book_id CHAR(13)
title VARCHAR(255)
authors VARCHAR(500)
categories VARCHAR(255)
available tinyint(1)
Here book_id is the ISBN number of the book and categories is the genre the book belongs to
Members
Field type
member_id CHAR(7)
member_name VARCHAR(500)
issued_books VARCHAR(490)
member_dues int
Issues
Field type
issue_id CHAR(7)
book_id CHAR(13)
member_id CHAR(7)
issue_date date
return_date date
is_returned tinyint(1)
Admins
Field type
admin_username CHAR(7)
admin_password CHAR(13)
Source Structure
Execution Method
The first option allows the admin to enter their username and
password. Actual credentials are stored in the “admins” table which
are checked for equality with the ones entered. The second option
allows the user to enter a member id and their name to create a new
user.
Options Available:
executed for each of the tasks. Therefore the python interface acts as
a user-friendly and error-checking layer for the system. The following
diagram explains the execution properly.
User Option
enters Handler
option
mysql.conn
ector
Mysql Query
Execution
Testing
# welcome text
print(welcome_text)
# options text
print(
"""
Select Action
1. Login as Librarian
"""
if choice == 1:
# handle login
login = False
login = librarian_interface.admin_login()
if login == True:
break
else:
# list options
print(
"""
8. Exit
"""
while True:
if int(choice) == 1:
librarian_interface.add_book()
if int(choice) == 2:
librarian_interface.remove_book()
librarian_interface.issue_book()
if int(choice) == 4:
librarian_interface.return_book()
if int(choice) == 5:
librarian_interface.books_due_today()
if int(choice) == 6:
librarian_interface.all_books_due()
if int(choice) == 7:
librarian_interface.remove_dues()
if int(choice) == 8:
break
else:
if choice == 2:
librarian_interface.add_member(member_name,member_id)
Librarian_interface.py
import utils
conn = utils.create_connection()
cursor = conn.cursor()
def admin_login():
data = (username,)
cursor.execute(query, data)
result = cursor.fetchone()
db_passwd = result[0]
if entered_passwd == db_passwd:
return True
else:
return False
def add_book():
return
book_name = input("Enter name of book: ")
try:
cursor.execute(query, data)
conn.commit()
except:
return
def remove_book():
book_id = input(
"Enter the isbn number of book to be removed from the library: ")
return
try:
cursor.execute(query)
except:
def issue_book():
book_id = input(
return
mem_id)
cursor.execute(check_member_query)
result1 = cursor.fetchone()
book_id)
cursor.execute(check_book_query)
result2 = cursor.fetchone()
return
# random issue id
issue_id = str(utils.random_number(7))
"Input issue date in YYYY-mm-dd format (or press enter to input today's date): ")
cursor.execute(q1)
d = cursor.fetchone()
books = d[0].split()
books.append(book_id)
books = ",".join(books)
books, mem_id)
cursor.execute(q2)
conn.commit()
cursor.execute(q3)
conn.commit()
try:
cursor.execute(query, data)
conn.commit()
print("\n")
except:
def return_book():
return
book_id)
cursor.execute(query)
data = cursor.fetchone()
if data == None:
actual_return_date = input(
"Input the date when student returned the book in YYYY-mm-dd format (or press enter to input today's
date): ")
# get difference between actual_return_date and return_date and calculate late fine
b = datetime.strptime(str(actual_return_date), "%Y-%m-%d")
a = datetime.strptime(str(data[3]), "%Y-%m-%d")
delta = b - a
number_of_days_late = delta.days
if number_of_days_late < 0:
late_fine = 0
else:
late_fine = number_of_days_late * 10
try:
cursor.execute(q1)
conn.commit()
data[1])
cursor.execute(q2)
d = cursor.fetchone()
books = d[0].split()
books.remove(book_id)
books = ",".join(books)
cursor.execute(q3)
conn.commit()
except:
cursor.execute(q3)
conn.commit()
def books_due_today():
return_date = input(
"Input date to see list of books due on that date(or press enter to input today's date): ")
cursor.execute(query)
data = cursor.fetchall()
print("\n")
cursor.execute(q2)
data = cursor.fetchone()
book_name = data[0]
cursor.execute(q3)
data = cursor.fetchone()
member_name = data[0]
print(row[0],'\t',book_name,'\t','\t',row[1],'\t',member_name)
def all_books_due():
cursor.execute(query)
data = cursor.fetchall()
print("\n")
cursor.execute(q2)
data = cursor.fetchone()
book_name = data[0]
cursor.execute(q3)
data = cursor.fetchone()
member_name = data[0]
print(row[0],'\t','\t','\t',book_name,'\t','\t','\t',row[1],'\t','\t','\t',member_name)
def remove_dues():
member_id = input("Enter the id of the member to clear the late fines: ")
cursor.execute(q)
conn.commit()
def add_member(member_name,member_id):
data = (member_id,member_name,"",0)
cursor.execute(query,data)
conn.commit()
print("Member added.")
utils.py
def create_connection():
conn = connector.connect(user='ashklempton',passwd='ash12345',host='localhost',database='librarydb')
return conn
def random_number(n):
range_start = 10**(n-1)
range_end = (10**n)-1
Return book