Cs Project Sofy
Cs Project Sofy
Investigatory Project
Topic : Library Management System
Made By:-
Jay Thakkar
Class :XII
Roll No:
Date :
INDEX
Certificate 4
Introduction 6
Modules 8
Code 12
Output 42
Conclusion 48
Analysis 48
Bibliography 49
Teacher’s remarks 50
ACKNOWLEDGEMENT
I would like to thank our respected Principal,
Mr. Chaitanya Chilamkuri Sir for his mutual
support. I would also like to express my gratitude
to my computer science teacher ,
Mrs. Neelu Raina madam for giving me the golden
opportunity to work on the wonderful computer
science project. Finally I would like to thank
CBSE for giving me this opportunity to undertake
this project.
I would also like to acknowledge the support and
help that was provided by my teachers and friends
for helping me to complete the given project
within the stipulated time.
CERTIFICATE
EXAMINATION ROLL NO:
This is to certify that Mst Jay Thakkar of Class
XII-A has satisfactorily completed his computer
science project work on the topic LIBRARY
MANAGEMENT SYSTEM, for AISSCE as
prescribed by CBSE for the year 2022-2023.
Date: _____________
_________________ ________________
Staff member in charge of Signature of the Principal
the batch
__________________ _________________
Rubber stamp of the school Signature of the External
Examiner
INTRODUCTION and
STATEMENT OF PURPOSE
Syntax:
I. Tk(screenName=None, baseName=None,
className=’Tk’, useTk=1)
To create a main window
II. mainloop()
There is a method known by the name
mainloop() is used when your application
is ready to run.
Widgets:
i. Button: To add a button in your application,
this widget is used.
Button(window, text= ‘’, command = , bg
= ‘’, fg = ‘’, image = ‘<image_path>’,
width = ‘’, height = ‘’)
ii. Entry: It is used to input the single line text
entry from the user.
1. MySQL.connector
Syntax:
mysql.connector.connect(host = ‘’, user = ‘’,
passwd = ‘’, database = ‘’)
Connects with Python with MySQL.
cursor()
Cursor objects interact with the MySQL server
using a MySQLConnection object.
execute(‘<query>’)
Executes the MySQL command through
Python Interface.
fetchall()
Used for extracting data from the executed
command.
commit()
sends a COMMIT statement to the MySQL
server, committing the current transaction.
2. time
This module provides various time-related
functions.
Syntax:
I. time.sleep(secs)
Suspend execution of the calling thread
for the given number of seconds.
3. OS
The OS module in Python provides functions for
interacting with the operating system.
Syntax:
os.listdir()
Used to get the list of all files and directories
in the specified directory.
os.path.dirname(path)
Return the directory name of pathname path.
4. PIL
PIL stands for Python Imaging Library. It adds
image processing capabilities to your Python
interpreter. This library provides extensive file
format support, an efficient internal representation,
and fairly powerful image processing capabilities.
Syntax:
ImageTK.PhotoImage(Image.open(‘<image_path>
’).resize((width, height)))
5. random
Random module is an in-built module of Python
which is used to generate random numbers.
PROGRAM CODE:
#-------------------------------------------------------------------STUDENT
LOGIN
SYSTEM------------------------------------------------------------------------
------------------
def login_student_window():
def login_window():
#connecting to the database
db =
mysql.connector.connect(host="localhost",user="root",passwd="tiger
",database="jay")
mycur = db.cursor()
def error_destroy():
err.destroy()
def succ_destroy():
succ.destroy()
win.destroy()
def error():
global err
err = Toplevel()
err.title("Error")
err.geometry("200x100")
Label(err,text="..",fg="red",font="bold").pack()
Label(err,text="").pack()
Button(err,text="Ok",bg="grey",width=8,height=1,command=error_d
estroy).pack()
def success():
messagebox.showinfo("Success","Registration
Successfull")
def register_user():
username_info = username_registration.get()
password_info = password_registration.get()
if username_info == "":
error()
elif password_info == "":
error()
else:
sql = "insert into login values(%s,%s)"
t = (username_info, password_info)
mycur.execute(sql, t)
db.commit()
Label(win, text="").pack()
time.sleep(0.50)
success()
def registration():
global win,username_registration,password_registration
win= Tk()
win.title("Log-IN Portal")
win.geometry("300x300")
Canvas1 = Canvas(win)
Canvas1.config(bg="#f8b0b8")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(win,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13
)
headingLabel = Label(headingFrame1, text="Register Your
Account", bg='black', fg='white', font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)
labelFrame = Frame(win,bg='black')
labelFrame.place(relx=0.1,rely=0.4,relwidth=0.8,relheight=0.4)
# USERNAME_REGISTRATION
username_label = Label(labelFrame,text="Username : ",
bg='black', fg='white')
username_label.place(relx=0.05,rely=0.2, relheight=0.08)
username_registration = Entry(labelFrame)
username_registration.place(relx=0.3,rely=0.2,
relwidth=0.62, relheight=0.08)
# PASSWORD_REGISTRATION
password_label = Label(labelFrame,text="Password : ",
bg='black', fg='white')
password_label.place(relx=0.05,rely=0.35, relheight=0.08)
win.mainloop()
def login():
global win,username_check,password_check
win= Tk()
win.title("Log-IN Portal")
win.geometry("300x300")
Canvas1 = Canvas(win)
Canvas1.config(bg="#cc2b5e")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(win,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13
)
headingLabel = Label(headingFrame1, text="LOGIN
WINDOW", bg='black', fg='white', font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)
labelFrame = Frame(win,bg='black')
labelFrame.place(relx=0.1,rely=0.4,relwidth=0.8,relheight=0.4)
# USERNAME
username_label = Label(labelFrame,text="Username : ",
bg='black', fg='white')
username_label.place(relx=0.05,rely=0.2, relheight=0.08)
username_check = Entry(labelFrame)
username_check.place(relx=0.3,rely=0.2, relwidth=0.62,
relheight=0.08)
# PASSWORD
password_label = Label(labelFrame,text="Password : ",
bg='black', fg='white')
password_label.place(relx=0.05,rely=0.35, relheight=0.08)
win.mainloop()
def logg_destroy():
logg.destroy()
win.destroy()
def fail_destroy():
fail.destroy()
def failed():
global fail
fail = Toplevel(win)
fail.title("Invalid")
fail.geometry("200x100")
Label(fail, text="Invalid credentials...", fg="red",
font="bold").pack()
Label(fail, text="").pack()
Button(fail, text="Ok", bg="grey", width=8, height=1,
command=fail_destroy).pack()
def login_varify():
user_varify = username_check.get()
pas_varify = password_check.get()
sql = "select * from login where Username = %s and
Password = %s"
mycur.execute(sql,[(user_varify),(pas_varify)])
results = mycur.fetchall()
if results:
for i in results:
student_window()
break
else:
failed()
def main_screen():
global win
win= Tk()
win.title("Log-IN Portal")
win.geometry("300x300")
Canvas1 = Canvas(win)
Canvas1.config(bg="#ff6e40")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(win,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13
)
headingLabel = Label(headingFrame1, text="Login-In
Portal", bg='black', fg='white', font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)
labelFrame = Frame(win,bg='black')
labelFrame.place(relx=0.1,rely=0.4,relwidth=0.8,relheight=0.4)
lgn_btn = Button(win,text = "LOGIN",borderwidth =
5,command= login)
lgn_btn.place(relx = 0.17, rely = 0.5 ,relwidth =
0.3,relheight= 0.12)
register_btn = Button(win,text="REGISTER",borderwidth
= 5,command = registration)
register_btn.place(relx = 0.55,rely = 0.5,relwidth =
0.3,relheight = 0.12)
main_screen()
win.mainloop()
login_window()
#--------------------------------------------------------------------------
ADMIN USER LOGIN
SYSTEM------------------------------------------------------------------------
----------------------------
def login_teacher_window():
def teacher_login_verify():
db =
mysql.connector.connect(host="localhost",user="root",passwd="tiger
",database="jay")
mycur = db.cursor()
user_verify = teacher_username_check.get()
pas_verify = teacher_password_check.get()
sql = "select * from login_teacher where ADMIN_NAME =
%s and PASSWORD = %s"
mycur.execute(sql,[(user_verify),(pas_verify)])
results = mycur.fetchall()
if results:
for i in results:
main_teacher_window()
break
else:
messagebox.showinfo("Invalid!!","Invalid Credentials
entered")
def login():
global
tab,teacher_username_check,teacher_password_check
tab= Tk()
tab.title("Log-IN Portal")
tab.geometry("300x300")
Canvas1 = Canvas(tab)
Canvas1.config(bg="#eb3349")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(tab,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13
)
headingLabel = Label(headingFrame1, text="LOGIN
WINDOW", bg='black', fg='white', font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)
labelFrame = Frame(tab,bg='black')
labelFrame.place(relx=0.1,rely=0.4,relwidth=0.8,relheight=0.4)
# TEACHER_USERNAME
teacher_username_label =
Label(labelFrame,text="Username : ", bg='black', fg='white')
teacher_username_label.place(relx=0.05,rely=0.2,
relheight=0.08)
teacher_username_check = Entry(labelFrame)
teacher_username_check.place(relx=0.3,rely=0.2,
relwidth=0.62, relheight=0.08)
# TEACHER_PASSWORD
teacher_password_label =
Label(labelFrame,text="Password : ", bg='black', fg='white')
teacher_password_label.place(relx=0.05,rely=0.35,
relheight=0.08)
tab.mainloop()
login()
#-----------------------------------------------------------------------------------
------THE MAIN ADMIN
WINDOW-----------------------------------------------------------------------
---------------------
def main_teacher_window():
#MAJORLY REQUIRED
FUNCTIONS-------------------------------------------------------------------
------------------------------------------------------------------------------------
---------------
#Adding book task functions
def bookRegister():
bid = bookInfo1.get()
title = bookInfo2.get()
author = bookInfo3.get()
status = bookInfo4.get()
issuedby = bookInfo5.get()
status = status.lower()
print(bid)
print(title)
print(author)
print(status)
root.destroy()
def addBook():
global
bookInfo1,bookInfo2,bookInfo3,bookInfo4,bookInfo5,Canvas1,con,c
ur,bookTable,root
root = Tk()
root.title("Library")
root.minsize(width=400,height=400)
root.geometry("600x500")
con =
pymysql.connect(host="localhost",user="root",passwd="tiger",databa
se="jay")
cur = con.cursor()
# Enter Table Names here
bookTable = "books" # Book Table
Canvas1 = Canvas(root)
Canvas1.config(bg="#ff6e40")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13
)
labelFrame = Frame(root,bg='black')
labelFrame.place(relx=0.1,rely=0.4,relwidth=0.8,relheight=0.4)
# Book ID
lb1 = Label(labelFrame,text="Book ID : ", bg='black',
fg='white')
lb1.place(relx=0.05,rely=0.2, relheight=0.08)
bookInfo1 = Entry(labelFrame)
bookInfo1.place(relx=0.3,rely=0.2, relwidth=0.62,
relheight=0.08)
# Title
lb2 = Label(labelFrame,text="Title : ", bg='black', fg='white')
lb2.place(relx=0.05,rely=0.35, relheight=0.08)
bookInfo2 = Entry(labelFrame)
bookInfo2.place(relx=0.3,rely=0.35, relwidth=0.62,
relheight=0.08)
# Book Author
lb3 = Label(labelFrame,text="Author : ", bg='black', fg='white')
lb3.place(relx=0.05,rely=0.50, relheight=0.08)
bookInfo3 = Entry(labelFrame)
bookInfo3.place(relx=0.3,rely=0.50, relwidth=0.62,
relheight=0.08)
# Book Status
lb4 = Label(labelFrame,text="Status(Avail/issued) : ",
bg='black', fg='white')
lb4.place(relx=0.05,rely=0.65, relheight=0.08)
bookInfo4 = Entry(labelFrame)
bookInfo4.place(relx=0.3,rely=0.65, relwidth=0.62,
relheight=0.08)
#Book IssuedBy
lb5 = Label(labelFrame , text = "IssuedBy : ",bg= "black",fg =
"white")
lb5.place(relx = 0.05,rely =0.80,relheight = 0.08)
bookInfo5 = Entry(labelFrame)
bookInfo5.place(relx=0.3,rely=0.80, relwidth=0.62,
relheight=0.08)
#Submit Button
SubmitBtn = Button(root,text="SUBMIT",bg='#d1ccc0',
fg='black',command=bookRegister)
SubmitBtn.place(relx=0.28,rely=0.9,
relwidth=0.18,relheight=0.08)
root.mainloop()
#the view student_users
funtion----------------------------------------------------------------------------
-------------------------------------------------
con = pymysql.connect(host="localhost",user="root",passwd=
"tiger" ,database="jay")
cur = con.cursor()
# Enter Table Names here
StudentTable = "login"
def Viewstudentusers():
root = Tk()
root.title("Existing Students Users")
root.minsize(width=400,height=400)
root.geometry("600x500")
Canvas1 = Canvas(root)
Canvas1.config(bg="#06beb6")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#FFB853",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13
)
labelFrame = Frame(root,bg='black')
labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.5)
y = 0.25
Label(labelFrame, text="%-50s"%
('Username'),bg='black',fg='white').place(relx=0.40,rely=0.1)
Label(labelFrame,
text="----------------------------------------------------------------------------"
,bg='black',fg='white').place(relx=0.05,rely=0.2)
getusers = "select * from "+StudentTable
try:
cur.execute(getusers)
con.commit()
for i in cur:
Label(labelFrame,text = i[0],bg = "black",fg =
"white").place(relx = 0.40,rely = y )
y += 0.1
except:
messagebox.showinfo("Failed to files from database")
root.mainloop()
#Delete Books Function
------------------------------------------------------------------------------------
------------------------------------------------
# Enter Table Names here
issueTable = "books_issued"
bookTable = "books" #Book Table
def deleteBook():
bid = bookInfo1.get()
print(bid)
bookInfo1.delete(0, END)
root.destroy()
def delete():
global
bookInfo1,bookInfo2,bookInfo3,bookInfo4,Canvas1,con,cur,bookTab
le,root
root = Tk()
root.title("Library")
root.minsize(width=400,height=400)
root.geometry("600x500")
Canvas1 = Canvas(root)
Canvas1.config(bg="#006B38")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13
)
labelFrame = Frame(root,bg='black')
labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.5)
# Book ID to Delete
lb2 = Label(labelFrame,text="Book ID : ", bg='black',
fg='white')
lb2.place(relx=0.05,rely=0.5)
bookInfo1 = Entry(labelFrame)
bookInfo1.place(relx=0.3,rely=0.5, relwidth=0.62)
#Submit Button
SubmitBtn = Button(root,text="SUBMIT",bg='#d1ccc0',
fg='black',command=deleteBook)
SubmitBtn.place(relx=0.28,rely=0.9,
relwidth=0.18,relheight=0.08)
def View():
root = Tk()
root.title("Library")
root.minsize(width=400,height=400)
root.geometry("600x500")
Canvas1 = Canvas(root)
Canvas1.config(bg="#12a4d9")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13
)
labelFrame = Frame(root,bg='black')
labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.5)
y = 0.25
Label(labelFrame, text="%-10s%-40s%-30s%-20s"%
('BID','Title','Author','Status'),bg='black',fg='white').place(relx=0.07,r
ely=0.1)
Label(labelFrame,
text="----------------------------------------------------------------------------"
,bg='black',fg='white').place(relx=0.05,rely=0.2)
getBooks = "select * from "+bookTable
try:
cur.execute(getBooks)
con.commit()
for i in cur:
Label(labelFrame, text="%-10s%-30s%-30s%-20s"%
(i[0],i[1],i[2],i[3]),bg='black',fg='white').place(relx=0.07,rely=y)
y += 0.1
except:
messagebox.showinfo("Failed to fetch files from database")
root.mainloop()
root = Toplevel()
root.title("Library")
root.minsize(width=400,height=400)
root.geometry("600x500")
newImageSizeWidth = int(imageSizeWidth*n)
if same:
newImageSizeHeight = int(imageSizeHeight*n)
else:
newImageSizeHeight = int(imageSizeHeight/n)
background_image =
background_image.resize((newImageSizeWidth,newImageSizeHeight
),Image.ANTIALIAS)
img = ImageTk.PhotoImage(background_image)
Canvas1 = Canvas(root)
Canvas1.create_image(300,340,image = img)
Canvas1.config(bg="white",width = newImageSizeWidth, height =
newImageSizeHeight)
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.2,rely=0.1,relwidth=0.6,relheight=0.16)
root.mainloop()
root.waitwindow()
#-----------------------------------------------------------------------------------
------STUDENT USER WINDOW
------------------------------------------------------------------------------------
----
def student_window():
#Majorly used functions ---------------------------------------------------
con = pymysql.connect(host="localhost",user="root",passwd=
"tiger" ,database="jay")
cur = con.cursor()
bookTable = "books"
def View():
root = Tk()
root.title("Library")
root.minsize(width=400,height=400)
root.geometry("600x500")
Canvas1 = Canvas(root)
Canvas1.config(bg="#12a4d9")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13
)
labelFrame = Frame(root,bg='black')
labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.5)
y = 0.25
Label(labelFrame, text="%-10s%-40s%-30s%-20s"%
('BID','Title','Author','Status'),bg='black',fg='white').place(relx=0.07,r
ely=0.1)
Label(labelFrame,
text="----------------------------------------------------------------------------"
,bg='black',fg='white').place(relx=0.05,rely=0.2)
getBooks = "select * from "+bookTable
try:
cur.execute(getBooks)
con.commit()
for i in cur:
Label(labelFrame, text="%-10s%-30s%-30s%-20s"%
(i[0],i[1],i[2],i[3]),bg='black',fg='white').place(relx=0.07,rely=y)
y += 0.1
except:
messagebox.showinfo("Failed to fetch files from database")
background_image =
background_image.resize((newImageSizeWidth,newImageSizeHeight
),Image.ANTIALIAS)
img = ImageTk.PhotoImage(background_image)
Canvas1 = Canvas(root)
Canvas1.create_image(300,340,image = img)
Canvas1.config(bg="white",width = newImageSizeWidth, height =
newImageSizeHeight)
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="#69359c",bd=5)
headingFrame1.place(relx=0.2,rely=0.1,relwidth=0.6,relheight=0.16)
root.mainloop()
root.waitwindow()
#---------------------------------------------------------------MAIN
WINDOW DESIGNING
PART-----------------------------------------------------------------------------
--------------------
main_window= Tk()
main_window.configure(bg = "black")
#--------------------------------Title
Frame-----------------------------------------
label_title = Label(main_window,text="Library Management
System",bg="#DCAE96",fg="black",bd=20,relief=RIDGE,font=("tim
es new roman",20,"bold"),padx=2,pady=6)
label_title.pack(side=TOP,fill=X)
#the main commanding buttons for taking the user to its required
destination
#the student directing button
btn_studentdirecting = Button(main_window,text = "STUDENT
USER",bg="#DCAE96",fg="black",bd=20,relief=RIDGE,font=("time
s new roman",20,"bold"),padx=100,pady=100,command =
login_student_window)
btn_studentdirecting.place(x = 100 , y= 200)
#OUTPUTS
Outputs from mysql:-
#outputs
#the main window
#the student login portal
ANALYSIS:
This project has helped me to understand the basics of
python programming and to gain hands-on experience
on testing this knowledge of error handling, data
validation, connectivity between python frontend and
mysql database backend.
BIBLIOGRAPHY :
Stationary refered:
o Computer Science With PYTHON By
Sumita Arora
Websites for learning part:-
o https://docs.python.org/3/tutorial
o https://www.w3school.com/python/
o https://tkdocs.com
o https://www.tutorialspoint.com/python
•Websites reffered:-
›https://data-flair.training/blogs/library
management-system-python-project/
TEACHER’S REMARKS
Remarks:
Signature: