TOPIC : LIBRARY MANAGEMENT PROJECT
CBSE ROLL NO. : ………………………….
SESSION : 2023-2024
TRS GLOBAL PUBLIC SCHOOL SENIOR SECONDARY CBSE
Computer Science (Python)
CLASS 12TH
Name : Madhan Sai Raghavendra B V
SUBMITTED TO : CBSE,
Under The guidance Of Mr. Manoj Kumar T
Date : 12th December, 2024 .
TRS GLOBAL
PUBLIC SCHOOL
CERTIFICATE
This is to certify that Master Madhan Sai
Raghavendra B V studying in TRS
GLOBAL PUBLIC SCHOOL
of standard 12th Science group has
completed Computer Science (python)
project under the guidance of Mr. T. Manoj
Kumar
Swarnalatha J
(PRINCIPAL)
ACKNOWLEDGEMENT
I express my deep gratitude and appreciation to
those who agreed in this project, for their time
expended and courage in sharing their insights
with a fledging student . It is to them that I am
most indebted, and I can only hope that the
product of our collaboration benefits each one
as much as I benefited from the process.
I had been immeasurably enriched by working
under the guidance of Mr. T. Manoj Kumar the
subject teacher ,who has a great level of
knowledge and who has an art of encouraging ,
correcting and directing me in every situation
possible, which has enabled me to complete the
project.
I acknowledge to all the people who have
involved and supported me in making this
project.
With thanks…
Madhan Sai Raghavendra B V
Grade 12 science group
THANKS
MYSELF MADHAN SAI RAGHAVENDRA
B V, FEELING SO THANKFUL TO OUR
HOUNERABLE PRINCIPLE MA’AM
SWARNALATHA J WHO ENCOURAGED
US TO FACE PROBLEM ANALYTICALLY
AND MY WORTHY COMPUTER TEACHER
Mr. T. MANOJ KUMAR WHO INSPIRED
US AND ACKNOWLEDGE US ALL THE
VALUABLE SUGGESTION FOR
IMPROVEMENT OF PROJECT . AND I
ALSO WANT TO THANK A LOT TO CBSE
WHICH PROVIDES US A BIG GOLDEN
OPPORTUNITY BY WHICH WE GET SOME
PRACTICAL KNOWLEDGE OF DAY TO
DAY TO WORKING.
LIBRARY MANAGEMENT
SYSTEM
BIBLIOGRAPHY
1. Computer Science with Python 12th
NCERT
2. Computer Science with Python 12th
preeti arora
3. Computer Science with Python 12th
sumita arora
4. [Link]
CONTENS
INTRODUCTION
Python Library Management
Project Prerequisites:
To build this project, we will need the
following Python libraries:
1. Tkinter – To create the GUI
a. messagebox – To display boxes
showing information or error or asking
yes or no.
b. [Link] – To display all the
information in the GUI window.
c. simpledialog – To use pre-defined
simple dialog boxes provided by Tkinter.
2. SQLite – To connect to the database
and perform operations in it
SOURCE CODE
# Importing all necessary modules
import sqlite3
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():
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]()
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
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"]
[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?')
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)
# 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'])
[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])
[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]()
Output Of The Project
Thank you