0% found this document useful (0 votes)
5 views18 pages

Library Management System Project

Uploaded by

darylshyju
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views18 pages

Library Management System Project

Uploaded by

darylshyju
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

BAHRAIN INDIAN SCHOOL

Block 473, Budaiya Post office,


Kingdom of Bahrain.

COMPUTER SCIENCE
RECORD

1|Page
CERTIFICATE

This is to certify that Krissh Nambiar of class XII


Cooper of Bahrain Indian School has done his
project on Library Management under my
supervision. He has taken interest and shown at
most sincerity in completion of this project.

I certify this Project is up to my expectation & as


per guidelines issued by CBSE, NEW DELHI

Internal Examiner External Examiner

2|Page
ACKNOWLEDGMENT

It is with pleasure that I acknowledge my sincere


gratitude to our teacher, Mrs. Nasreena Hameeda
Jahabardeen who taught and undertook the
responsibility of teaching the subject computer
science. I have greatly benefited from his classes.

I am especially indebted to our Principal Mr. Saji


Jacob who has always been a source of
encouragement and support, without whose
inspiration this project wouldn’t have been successful
I would like to place on record a heartfelt thanks to
him.

Finally, I would like to express my sincere


appreciation to all the other students of my batch for
their friendship & the fine times that we all shared
together.

1|Page
[Link] Contents Page No.

1 Introduction
1.1. Abstract
1.2. Project Overview

2 System Requirements
2.1. User Requirements
2.2. Software Requirements
2.3. Hardware
Requirements

3
Project Code

4
Project Outputs

5
Conclusion

2|Page
6
Bibliography
Introduction

1. Abstract

The Library Management System is a Python-based


application designed to facilitate the management of a
library's inventory.
The system provides a user-friendly interface for
adding, viewing, updating, and deleting book records. It
also allows for the modification of book availability
status and management of issuer card IDs.
The program utilizes the tkinter library for GUI
development and sqlite3 for database operations. With
its intuitive design and comprehensive functionality,
the Library Management System offers an efficient
solution for organizing and maintaining library
collections.

2. Project overview

a) Purpose: The purpose of this project is to develop a


user-friendly Python-based application for managing a
library's inventory, providing features for adding,
viewing, updating, and deleting book records, as well as
modifying book availability status and managing issuer
card IDs.
b) Scope: The scope of the project includes creating a
graphical user interface using the tkinter library,
implementing database operations with sqlite3, and
3|Page
offering comprehensive functionality for efficient
organization and maintenance of library collections.

System Requirements

2.1 User Requirements

Operating System : Platform Independent


Processor : Dual core or above
Hard Disk : 20GB
RAM : 4GB

2.2 Software Requirements

Operating System : Windows 7/8/10/11


Platform : Python IDLE 3.10 and above
Database : SQLITE/MySQL
Languages : Python

2.2 Hardware Requirements

Processor : Dual core or above


Hard Disk : 20GB
RAM : 4GB

Program Code
import sqlite3
4|Page
from tkinter import *
import [Link] as ttk
import [Link] as mb
import [Link] as sd

# Connecting to Database
connector = [Link]('[Link]')
cursor = [Link]()
[Link](
'CREATE TABLE IF NOT EXISTS Library (BK_NAME TEXT, BK_ID
TEXT PRIMARY KEY NOT NULL, AUTHOR_NAME TEXT, BK_STATUS
TEXT, CARD_ID TEXT)'
)
# Functions
def issuer_card():
Cid = [Link]('Issuer Card ID', 'What is the
Issuer\'s Card ID?\t\t\t')

if not Cid:
[Link]('Issuer ID cannot be zero!', 'Can\'t
keep Issuer ID empty, it must have a value')
else:
return Cid

def display_records():
global connector, cursor
global tree

[Link](*tree.get_children())

curr = [Link]('SELECT * FROM Library')


data = [Link]()

for records in data:


[Link]('', END, values=records)

def clear_fields():

5|Page
global bk_status, bk_id, bk_name, author_name, card_id

bk_status.set('Available')
for i in ['bk_id', 'bk_name', 'author_name',
'card_id']:
exec(f"{i}.set('')")
bk_id_entry.config(state='normal')
try:
tree.selection_remove([Link]()[0])
except:
pass

def clear_and_display():
clear_fields()
display_records()

def add_record():
global connector
global bk_name, bk_id, author_name, bk_status

if bk_status.get() == 'Issued':
card_id.set(issuer_card())
else:
card_id.set('N/A')

surety = [Link]('Are you sure?',


'Are you sure this is the data you want to
enter?\nPlease note that Book ID cannot be changed in the
future')

if surety:
try:
[Link](
'INSERT INTO Library (BK_NAME, BK_ID,
AUTHOR_NAME, BK_STATUS, CARD_ID) VALUES (?, ?, ?, ?, ?)',
(bk_name.get(), bk_id.get(),
author_name.get(), bk_status.get(), card_id.get()))
[Link]()

6|Page
clear_and_display()

[Link]('Record added', 'The new record


was successfully added to your database')
except [Link]:
[Link]('Book ID already in use!',
'The Book ID you are trying to
enter is already in the database, please alter that
book\'s record or check any discrepancies on your side')

def view_record():
global bk_name, bk_id, bk_status, author_name, card_id
global tree

if not [Link]():
[Link]('Select a row!', 'To view a record,
you must select it in the table. Please do so before
continuing.')
return

current_item_selected = [Link]()
values_in_selected_item =
[Link](current_item_selected)
selection = values_in_selected_item['values']

bk_name.set(selection[0]) ;
bk_id.set(selection[1]) ; bk_status.set(selection[3])
author_name.set(selection[2])
try:
card_id.set(selection[4])
except:
card_id.set('')

def update_record():
def update():
global bk_status, bk_name, bk_id, author_name,
card_id

7|Page
global connector, tree

if bk_status.get() == 'Issued':
card_id.set(issuer_card())
else:
card_id.set('N/A')

[Link]('UPDATE Library SET BK_NAME=?,


BK_STATUS=?, AUTHOR_NAME=?, CARD_ID=? WHERE BK_ID=?',
(bk_name.get(), bk_status.get(),
author_name.get(), card_id.get(), bk_id.get()))
[Link]()

clear_and_display()

[Link]()
bk_id_entry.config(state='normal')
[Link](state='normal')

view_record()

bk_id_entry.config(state='disable')
[Link](state='disable')

edit = Button(left_frame, text='Update Record',


font=btn_font, bg=btn_hlb_bg, width=20, command=update)
[Link](x=50, y=375)

def remove_record():
if not [Link]():
[Link]('Error!', 'Please select an item from
the database')
return

current_item = [Link]()
values = [Link](current_item)
selection = values["values"]

8|Page
[Link]('DELETE FROM Library WHERE BK_ID=?',
(selection[1], ))
[Link]()

[Link](current_item)

[Link]('Done', 'The record you wanted deleted was


successfully deleted.')

clear_and_display()

def delete_inventory():
if [Link]('Are you sure?', 'Are you sure you want
to delete the entire inventory?\n\nThis command cannot be
reversed'):
[Link](*tree.get_children())

[Link]('DELETE FROM Library')


[Link]()
else:
return

def change_availability():
global card_id, tree, connector

if not [Link]():
[Link]('Error!', 'Please select a book from
the database')
return

current_item = [Link]()
values = [Link](current_item)
BK_id = values['values'][1]
BK_status = values["values"][3]

if BK_status == 'Issued':
surety = [Link]('Is return confirmed?', 'Has
the book been returned to you?')

9|Page
if surety:
[Link]('UPDATE Library SET
bk_status=?, card_id=? WHERE bk_id=?', ('Available',
'N/A', BK_id))
[Link]()
else: [Link](
'Cannot be returned', 'The book status cannot
be set to Available unless it has been returned')
else:
[Link]('UPDATE Library SET bk_status=?,
card_id=? where bk_id=?', ('Issued', issuer_card(),
BK_id))
[Link]()

clear_and_display()

# Variables
lf_bg = 'LightSkyBlue' # Left Frame Background Color
rtf_bg = 'DeepSkyBlue' # Right Top Frame Background Color
rbf_bg = 'DodgerBlue' # Right Bottom Frame Background
Color
btn_hlb_bg = 'SteelBlue' # Background color for Head
Labels and Buttons

lbl_font = ('Georgia', 13) # Font for all labels


entry_font = ('Times New Roman', 12) # Font for all Entry
widgets
btn_font = ('Gill Sans MT', 13)

# Initializing the main GUI window


root = Tk()
[Link]('PythonGeeks Library Management System')
[Link]('1010x530')
[Link](0, 0)

Label(root, text='LIBRARY MANAGEMENT SYSTEM', font=("Noto


Sans CJK TC", 15, 'bold'), bg=btn_hlb_bg,
fg='White').pack(side=TOP, fill=X)

10 | P a g e
# StringVars
bk_status = StringVar()
bk_name = StringVar()
bk_id = StringVar()
author_name = StringVar()
card_id = StringVar()

# Frames
left_frame = Frame(root, bg=lf_bg)
left_frame.place(x=0, y=30, relwidth=0.3, relheight=0.96)

RT_frame = Frame(root, bg=rtf_bg)


RT_frame.place(relx=0.3, y=30, relheight=0.2,
relwidth=0.7)

RB_frame = Frame(root)
RB_frame.place(relx=0.3, rely=0.24, relheight=0.785,
relwidth=0.7)

# Left Frame
Label(left_frame, text='Book Name', bg=lf_bg,
font=lbl_font).place(x=98, y=25)
Entry(left_frame, width=25, font=entry_font,
text=bk_name).place(x=45, y=55)

Label(left_frame, text='Book ID', bg=lf_bg,


font=lbl_font).place(x=110, y=105)
bk_id_entry = Entry(left_frame, width=25, font=entry_font,
text=bk_id)
bk_id_entry.place(x=45, y=135)

Label(left_frame, text='Author Name', bg=lf_bg,


font=lbl_font).place(x=90, y=185)
Entry(left_frame, width=25, font=entry_font,
text=author_name).place(x=45, y=215)

Label(left_frame, text='Status of the Book', bg=lf_bg,


font=lbl_font).place(x=75, y=265)
dd = OptionMenu(left_frame, bk_status, *['Available',
'Issued'])
11 | P a g e
[Link](font=entry_font, width=12)
[Link](x=75, y=300)

submit = Button(left_frame, text='Add new record',


font=btn_font, bg=btn_hlb_bg, width=20,
command=add_record)
[Link](x=50, y=375)

clear = Button(left_frame, text='Clear fields',


font=btn_font, bg=btn_hlb_bg, width=20,
command=clear_fields)
[Link](x=50, y=435)

# Right Top Frame


Button(RT_frame, text='Delete book record', font=btn_font,
bg=btn_hlb_bg, width=17, command=remove_record).place(x=8,
y=30)
Button(RT_frame, text='Delete full inventory',
font=btn_font, bg=btn_hlb_bg, width=17,
command=delete_inventory).place(x=178, y=30)
Button(RT_frame, text='Update book details',
font=btn_font, bg=btn_hlb_bg, width=17,
command=update_record).place(x=348, y=30)
Button(RT_frame, text='Change Book Availability',
font=btn_font, bg=btn_hlb_bg, width=19,
command=change_availability).place(x=518, y=30)

# Right Bottom Frame


Label(RB_frame, text='BOOK INVENTORY', bg=rbf_bg,
font=("Noto Sans CJK TC", 15, 'bold')).pack(side=TOP,
fill=X)

tree = [Link](RB_frame, selectmode=BROWSE,


columns=('Book Name', 'Book ID', 'Author', 'Status',
'Issuer Card ID'))

XScrollbar = Scrollbar(tree, orient=HORIZONTAL,


command=[Link])
YScrollbar = Scrollbar(tree, orient=VERTICAL,
command=[Link])
12 | P a g e
[Link](side=BOTTOM, fill=X)
[Link](side=RIGHT, fill=Y)

[Link](xscrollcommand=[Link],
yscrollcommand=[Link])

[Link]('Book Name', text='Book Name', anchor=CENTER)


[Link]('Book ID', text='Book ID', anchor=CENTER)
[Link]('Author', text='Author', anchor=CENTER)
[Link]('Status', text='Status of the Book',
anchor=CENTER)
[Link]('Issuer Card ID', text='Card ID of the
Issuer', anchor=CENTER)

[Link]('#0', width=0, stretch=NO)


[Link]('#1', width=225, stretch=NO)
[Link]('#2', width=70, stretch=NO)
[Link]('#3', width=150, stretch=NO)
[Link]('#4', width=105, stretch=NO)
[Link]('#5', width=132, stretch=NO)

[Link](y=30, x=0, relheight=0.9, relwidth=1)

clear_and_display()

# Finalizing the window


[Link]()
[Link]()

Program Output
Output 1:

13 | P a g e
Output 2:

14 | P a g e
Output 3:

Conclusion

I have successfully completed my python project on the


Library Management System with database connectivity.
The Library Management System is a Python-based
application that provides a user-friendly interface for
managing a library's inventory. The system allows for
adding, viewing, updating, and deleting book records, as
well as modifying book availability status and managing
issuer card IDs. The program utilizes the tkinter library for
GUI development and sqlite3 for database operations. With
its intuitive design and comprehensive functionality, the
Library Management System offers an efficient solution for
organizing and maintaining library collections.

15 | P a g e
Bibliography

[Link]
[Link]
[Link]
[Link]

16 | P a g e

You might also like