0% found this document useful (0 votes)
88 views52 pages

Cs Project Sofy

This document is a student's investigatory project on developing a library management system. It includes an index, acknowledgements, introduction, modules used including Tkinter, MySQL, time, OS, and PIL. It provides code snippets for the student login system including functions for registration, login validation, and error/success handling. The project aims to create an online system for library management with separate interfaces for students and administrators.

Uploaded by

Jay Thakkar
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)
88 views52 pages

Cs Project Sofy

This document is a student's investigatory project on developing a library management system. It includes an index, acknowledgements, introduction, modules used including Tkinter, MySQL, time, OS, and PIL. It provides code snippets for the student login system including functions for registration, login validation, and error/success handling. The project aims to create an online system for library management with separate interfaces for students and administrators.

Uploaded by

Jay Thakkar
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
You are on page 1/ 52

Computer Science

Investigatory Project
Topic : Library Management System

Made By:-
Jay Thakkar
Class :XII
Roll No:
Date :
INDEX

CONTENT PAGE NO.


Acknowledgement 3

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

This is my investigatory project based on the topic


library management system. I have made this online
library management system for basically two different
users, student and admin. Firstly the admin who is the
chief head of the Library, controls the whole system, by
adding, viewing, deleting books and also has a track of
the existing student users. The admin details can be
changed directly from the sequel database only.
Second the student users, I have created a login portal
for student registration for free and and from that
window student users can also login to the to the online
library. The students can access to the book list only.
MODULES

Tkinter is a standardised GUI library for Python. Python when


combined with Tkinter provides a fast and easy way to create GUI
applications. Tkinter provides a powerful object-oriented
interface to the Tk GUI Toolkit.

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.

Entry(window, textvariable = ‘’, width =


‘’, justify = )

iii. Frame: It acts as a container to hold the


widgets. It is used for grouping and
organizing the widgets.

Frame(window, text = ‘’, bg = ‘’, width =


‘’, height = ‘’)

iv. Label: It refers to the display box where you


can put any text or image which can be
updated any time as per the code.
Label(window, text=‘’,font=(font,
size,style), bg=‘’, fg=‘’, width=‘’, image
=‘<image_path>’)

v. TopLevel: This widget is directly controlled


by the window manager. It don’t need any
parent window to work on.
Toplevel(window)
vi. Messagebox: This widget is just used to
show a pop which has a message written
inside it.
Messagebox.info(“label_of_the_messagebo
x”,”info_to_display”)

1. MySQL.connector

MySQL Connector is a standardized database


driver provided by MySQL to access the MySQL
database from Python.

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.

II. time.strftime(format[, t])


Returns the following as per the given t :-
%d - Day of the month as a decimal
number [01,31].
%m - Month as a decimal number [01,12].
%y - Year without century as a decimal
number [00,99].

%H - Hour (24-hour clock) as a decimal


number [00,23].
%M - Minute as a decimal number
[00,59].
%S - Second as a decimal number [00,61].

3. OS
The OS module in Python provides functions for
interacting with the operating system.

os.path - This module implements some useful


functions on pathnames.

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:

from tkinter import *


from PIL import ImageTk,Image
import pymysql
import mysql.connector
from tkinter import messagebox
import os
import time

#-------------------------------------------------------------------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)

password_registration = Entry(labelFrame,show = "*")


password_registration.place(relx=0.3,rely=0.35,
relwidth=0.62, relheight=0.08)
register_button =
Button(win,text="REGISTER",width="5",height="1",font="bold",co
mmand=register_user,borderwidth = 5)
register_button.place(relx = 0.4 , rely = 0.60, relheight =
0.15, relwidth= 0.30)

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)

password_check = Entry(labelFrame,show = "*")


password_check.place(relx=0.3,rely=0.35, relwidth=0.62,
relheight=0.08)
login_button = Button(win,text="Log-
IN",width="5",height="1",font="bold",command=login_varify,border
width = 5)
login_button.place(relx = 0.4 , rely = 0.60, relheight = 0.15,
relwidth= 0.30)

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)

teacher_password_check = Entry(labelFrame,show = "*")


teacher_password_check.place(relx=0.3,rely=0.35,
relwidth=0.62, relheight=0.08)
teacher_login_button = Button(tab,text="Log-
IN",width="5",height="1",font="bold",command=teacher_login_verif
y,borderwidth = 5)
teacher_login_button.place(relx = 0.4 , rely = 0.60,
relheight = 0.15, relwidth= 0.30)

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()

insertBooks = "insert into "+bookTable+"


values('"+bid+"','"+title+"','"+author+"','"+status+"','"+issuedby+"')"
try:
cur.execute(insertBooks)
con.commit()
messagebox.showinfo('Success',"Book added successfully")
except:
messagebox.showinfo("Error","Can't add data into Database")

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
)

headingLabel = Label(headingFrame1, text="Add Books",


bg='black', fg='white', font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)

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)

quitBtn = Button(root,text="Quit",bg='#f7f1e3', fg='black',


command=root.destroy)
quitBtn.place(relx=0.53,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
)

headingLabel = Label(headingFrame1, text="Existing Student


Users", bg='black', fg='white', font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)

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")

quitBtn = Button(root,text="Quit",bg='#f7f1e3', fg='black',


command=root.destroy)
quitBtn.place(relx=0.4,rely=0.9, relwidth=0.18,relheight=0.08)

root.mainloop()
#Delete Books Function
------------------------------------------------------------------------------------
------------------------------------------------
# Enter Table Names here
issueTable = "books_issued"
bookTable = "books" #Book Table

def deleteBook():

bid = bookInfo1.get()

deleteSql = "delete from "+bookTable+" where bid = '"+bid+"'"


deleteIssue = "delete from "+issueTable+" where bid =
'"+bid+"'"
try:
cur.execute(deleteSql)
con.commit()
cur.execute(deleteIssue)
con.commit()
messagebox.showinfo('Success',"Book Record Deleted
Successfully")
except:
messagebox.showinfo("Please check Book ID")

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
)

headingLabel = Label(headingFrame1, text="Delete Book",


bg='black', fg='white', font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)

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)

quitBtn = Button(root,text="Quit",bg='#f7f1e3', fg='black',


command=root.destroy)
quitBtn.place(relx=0.53,rely=0.9, relwidth=0.18,relheight=0.08)
root.mainloop()

#Viewing books function


------------------------------------------------------------------------------------
---------------------------------------------------------------------
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
)

headingLabel = Label(headingFrame1, text="View Books",


bg='black', fg='white', font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)

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")

quitBtn = Button(root,text="Quit",bg='#f7f1e3', fg='black',


command=root.destroy)
quitBtn.place(relx=0.4,rely=0.9, relwidth=0.18,relheight=0.08)

root.mainloop()

#The Main Window designing part


------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
----------------
con =
pymysql.connect(host="localhost",user="root",passwd="tiger",databa
se="jay")
cur = con.cursor()

root = Toplevel()
root.title("Library")
root.minsize(width=400,height=400)
root.geometry("600x500")

# Take n greater than 0.25 and less than 5


same=True
n=0.25

# Adding a background image


background_image =Image.open("lib.jpg")
[imageSizeWidth, imageSizeHeight] = background_image.size

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)

headingLabel = Label(headingFrame1, text="Welcome to \n


LIBRARY OF ALEXANDRIA", bg='black', fg='white',
font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)

btn1 = Button(root,text="Add Book Details",bg='black', fg='white',


command=addBook)
btn1.place(relx=0.28,rely=0.4, relwidth=0.45,relheight=0.125)

btn2 = Button(root,text="Delete Book",bg='black', fg='white',


command=delete)
btn2.place(relx=0.28,rely=0.5, relwidth=0.45,relheight=0.125)
btn3 = Button(root,text="View Book List",bg='black', fg='white',
command=View)
btn3.place(relx=0.28,rely=0.6, relwidth=0.45,relheight=0.125)

btn_4= Button(root,text="View Existing Student Users",bg='black',


fg='white', command=Viewstudentusers)
btn_4.place(relx=0.28,rely=0.7, relwidth=0.45,relheight=0.125)

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
)

headingLabel = Label(headingFrame1, text="View Ultimate


Book List", bg='black', fg='white', font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)

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")

quitBtn = Button(root,text="Quit",bg='#f7f1e3', fg='black',


command=root.destroy)
quitBtn.place(relx=0.4,rely=0.9, relwidth=0.18,relheight=0.08)
#designing the main window
---------------------------------------------------------------------------
root = Toplevel()
# Take n greater than 0.25 and less than 5
same=True
n=0.25

# Adding a background image


background_image =Image.open("lib.jpg")
[imageSizeWidth, imageSizeHeight] = background_image.size
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="#69359c",bd=5)

headingFrame1.place(relx=0.2,rely=0.1,relwidth=0.6,relheight=0.16)

headingLabel = Label(headingFrame1, text="Welcome to \n


LIBRARY OF ALEXANDRIA", bg='black', fg='white',
font=('Courier',15))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)
btn3 = Button(root,text="View Ultimate Book List",bg='black',
fg='white', command=View)
btn3.place(relx=0.28,rely=0.6, relwidth=0.45,relheight=0.125)

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)

#the admin user directing button


btn_teacherdirecting = Button(main_window, text = "ADMIN
USER",bg="#DCAE96",fg="black",bd=20,relief=RIDGE,font=("time
s new roman",20,"bold"),padx=100,pady=100,command =
login_teacher_window)
btn_teacherdirecting.place(x=700,y = 200)
main_window.mainloop()

#OUTPUTS
Outputs from mysql:-
#outputs
#the main window
#the student login portal

#the student login window


#student user register window

#student user registered successfully


#student user logged in

#admin user login window


#admin user logged in

#admin user functions


#adding books and existing users functions

#viewing books and deleting books


CONCLUSION:
So with the help of this library management system the
admin can clearly keep a track on the books, coming
and going and even on the existing student users using
this service . This can be further developed can be the
future of online library and even can be a contemporary
model for amazon kindle, and even can the upcoming
future of libraries.

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:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy