Library Mange Ment

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 23

LIBRARY MANAGEMENT

KENDRIYA
VIDYALAYA NO.1,
AFS PUNE-32
Student Details

Name: -

Class: - 12th C

Roll no: -

Subject: - Computer Science

Session: -

Subject Teacher: - Mr. Nitin Kumar Jain


PROJECT
SYNOPSIS
Group Members
1.
2.
3.
CERTIFICATE
This is to certify that ___________________
of Class XII-‘C’ has successfully
completed his project entitled “LIBRARY
MANAEMENT” for Session ________ in the
partial fulfilment of CBSE AISSCE
Examination, 2022-23 and has been carried
out under my supervision and guidance.

Date:

Signature:
Acknowledgement

I would like to express my special thanks of


gratitude to my teacher ‘Nitin Kumar Jain’
as well as our principal ‘Umakant Joshi’
who gave me the golden on the topic
‘Library Management’, which also helped
me in doing a lot of research and I came to
know about so many things I am really
thankful to them.

Secondly, I would also like to thank my


parents and friends who helped me a lot in
finalizing this project within the limited time
frame.
FRONT END
 Python
About the project

The library management system is basically


a database based on the project done with
help of python language. This project is very
useful to the librarian to keep a count on
what book they have and how much they
issued. This project is multifield project, so
that it can be modified for various
purposes.

Modules
1. Book data: This module contains
book relevant information such as a
book id, book name, book author
and no. of copies of book.
2. Member Detail: This module
contains information about the
member such as member id,
member name, class, phone no. and
gender of member.
3. Reports: This module stores book
detail, member details, issue detail,
return detail, no. of male and female
reader’s history.
4. Matter: This module deals with
issue and return of the book.
5. Exits: Exits the Program
Functions used:-
1. Tkinker - Python offers multiple
options for developing GUI (Graphical
User Interface).
2. Tabulate: - to show the output in
tabular formula.
3. try
4. input: - To take input from user
5. cursor
6. execute: - To execute the MySQL
statement.
7. connect
8. commit
9. fetchone
10. int
11. mysql.connector

Back end
MySQL

Interface
Coding
Books Handler
import mysql.connector as ms
from tabulate import tabulate
con = ms.connect(
host = 'localhost',
user = 'root',
password = 'Oppocharger@123',
database = 'library'
)
book_head = ['Book id', 'Name', 'Author', 'Copies', 'REM_COPIES']

def book_add():
cursor = con.cursor()

try:
BOOKID = input("Enter Book id : ")
NAME = input("Enter Name of The Book : ")
AUTHOR = input("Enter Name of Author : ")
COPIES = input("Enter no. of copies : ")
REM_COPIES = COPIES
sql = "insert into books values ({},'{}','{}',{},
{});".format(BOOKID,NAME,AUTHOR,COPIES,REM_COPIES)
cursor.execute(sql)
con.commit()
cursor.fetchone()
print("Added Sucessfully....")
except:
print("Error....Try Again")

def book_edit():
cursor = con.cursor()
try:
x = int(input("Enter Book id :"))
qry = "select * from books where BOOKID = {};".format(x)
cursor.execute(qry)
r = cursor.fetchone()
if r :
y = int(input("Enter new no. of copies : "))
qry = "update books set COPIES = {}, REM_COPIES = COPIES
where bookid = {};".format(y,x)
cursor.execute(qry)
con.commit()
print("Edited sucessfully .....")
else :
print("Wrong Book id....")
except:
print("Error...Try Again")

def book_search():
cursor = con.cursor()
print("1. Enter '1' for Book name search \n 2. Enter '2' for book
id search.")
ch = int(input("Enter your choice :"))

if ch == 1:
book_name = input("Enter some starting words of the Book : ")
qry = f"select * from books where NAME LIKE '{book_name}%'"
cursor.execute(qry)

myresult = cursor.fetchall()

print("\tFollowing Is The List of Members of Library:-")


a = list()
for y in myresult:
a.append(list(y))

print(tabulate(a, headers=book_head, tablefmt="grid"))

if ch == 2:
x = int(input("Enter The book id : "))
qry = "select * from books where bookid = {};".format(x)
cursor.execute(qry)

myresult = cursor.fetchall()

print("\tFollowing Is The List of Members of Library:-")


a = list()
for y in myresult:
a.append(list(y))

print(tabulate(a, headers=book_head, tablefmt="grid"))

def book_delete():
cursor = con.cursor()
sql = "select * from books ;"
cursor.execute(sql)
myresult = cursor.fetchall()

print("\tFollowing Is The List of Members of Library:-")


a = list()
for y in myresult:
a.append(list(y))

print(tabulate(a, headers=book_head, tablefmt="grid"))

book_id = int(input("Enter the Book id :"))


try:
qry = "DELETE from books where BOOKID = {};".format(book_id)
cursor.execute(qry)
con.commit()
print("Deleted Successfully ....")
except:
print("Entered id number is not in the list.")

 Members handler
import mysql.connector as ms
from tabulate import tabulate
mydb = ms.connect(
host = 'localhost',
user = 'root',
password = 'Oppocharger@123',
database = 'library'
)

head1 = ["memberid", "Name", "Class", "Mobile No."]

def insert_members():
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM show_members")
myresult = mycursor.fetchall()
sql = "INSERT INTO show_members (memberid, name, class, mobile)
VALUES (%s, %s, %s, %s)"
no_of_students = int(input("Enter the number of students to be
added:"))
for i in range(1,no_of_students+1):
name = input("Enter the Name to added (NOT NULL):")
id = int(input("Enter the id (NOT NULL):"))
clas = input("Enter the class (ex-8-C , NOT NULL) :")
mobile = int(input("Enter the Mobile number (10 digit
only):"))
val = (id, name, clas, mobile)
mycursor.execute(sql, val)
mydb.commit()
print("Record inserted")

d = list()
for x in myresult:

d.append(list(x))
print(tabulate(d, headers=head1, tablefmt="grid"))

insert_members()

def delete_members():
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM show_members")
myresult = mycursor.fetchall()
# myresult = mycursor.fetchall()
print("\tFollowing Is The List of Members of Library:-")
a = list()
for y in myresult:
a.append(list(y))

print(tabulate(a, headers=head1, tablefmt="grid"))

a_delete = input("Enter Name To Delete The Member:")


sql2 = f"DELETE FROM show_members WHERE name = %s;"
tup1 = (a_delete, )

mycursor.execute(sql2, tup1)
mydb.commit()
print()
print()
print()
print("\t\t AFTER DELETING THE MEMBER:")
print()
print()
print()
def up_tables():
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM show_members")
myresult = mycursor.fetchall()

a = list()
for y in myresult:
a.append(list(y))
print(tabulate(a, headers=head1, tablefmt="grid"))

up_tables()

def search_members():

"""This is used for searching name."""


mycursor = mydb.cursor()
print()
ch = int(input("Enter 1 for Name search and 2 for id search:"))
if ch == 1:

mem = input("Enter the Name or Some First Letter of The


Name:")
sql = f"SELECT * FROM show_members WHERE name LIKE '{mem}%';"
mycursor.execute(sql)
myresult = mycursor.fetchall()

print("\tFollowing Is The List of Members of Library:-")


a = list()
for y in myresult:
a.append(list(y))

print(tabulate(a, headers=head1, tablefmt="grid"))

if ch == 2:
id_no = int(input("Enter the id for search :"))
sql = f"SELECT * FROM show_members WHERE memberid LIKE
'{id_no}%';"
mycursor.execute(sql)
myresult = mycursor.fetchall()

print("\t\tFollowing Is The List of Members of Library:-")


a = list()
for y in myresult:
a.append(list(y))

print(tabulate(a, headers=head1, tablefmt="grid"))

Returning and Issuing code


 import mysql.connector as sql
from tabulate import tabulate
con = sql.connect(host='localhost', user='root',
password='Oppocharger@123', database='library')
cursor = con.cursor()

def book_issue():
try:
q = "select max(ISSUEID) from ISSUE;"
cursor.execute(q)
r = cursor.fetchone()[0]
if r :
issueid = r+1
else:
issueid = 1
x = int(input('Enter Member Id :'))
q1 = 'select * from show_members where MEMBERID =
{}'.format(x)
cursor.execute(q1)
r = cursor.fetchone()
print(r)
if r:
y = int(input('Enter book id :'))
q2 = 'select BOOKID, rem_copies from BOOKS where
BOOKID ={};'.format(y)
cursor.execute(q2)
print("here")
r = cursor.fetchone()
if r:
if r[1] > 0:
issuedate = input("Enter Issue date: ")
copies = int(input('Enter no. of copies : '))
rem_copies = r[1]-copies
q3 = 'INSERT into ISSUE values({},{},{},{},
{});'.format(issueid, issuedate, x, y, copies)
cursor.execute(q3)
con.commit()
r = cursor.fetchone()
q4 = 'UPDATE BOOKS set REM_COPIES = {} where
BOOKID = {};'.format(rem_copies, y)
cursor.execute(q4)
con.commit()
r = cursor.fetchone()
print("Book Issued")
else:
print("Book is not Available")
else:
print("Wrong Book ID")
else:
print("Wrong Member ID")
except Exception as d :
# print(d)
print("Error Try Again....")

Tkinter Interface
from tkinter import *
from book1 import *
from members import *

root = Tk()
root.geometry("800x600")

a_label =Label(text = " Library Mangement ",


bg = "red",
font=("arial",20,"bold"),
fg='black',
borderwidth=10,relief=GROOVE)
a_label.pack()

def quit1():
root.quit()

def book_details():
root = Tk()

f2 = Frame(root, bg='red', borderwidth=10, relief=GROOVE)


f2.pack(side=LEFT)

add_book = Button(f2,text='1.Add a book.',font=('arial', 20


,'bold'),command=book_add)
add_book.pack()
book_ed = Button(f2, text='2.Edit a Book',font=('arial', 20
,'bold'),command=book_edit)
book_ed.pack()
book_sea = Button(f2, text='3.Search a Book',font=('arial', 20
,'bold'),command=book_search)

book_sea.pack()
book_del = Button(f2, text='4. Delete a Book',font=('arial', 20
,'bold'),command=book_delete)
book_del.pack()
root.mainloop()
def member_details():
root = Tk()
f3 = Frame(root, bg = 'red', borderwidth=10,relief=GROOVE)
f3.pack()
insert_mem = Button(f3, text = '1.Insert a number.',font=('arial',
20 ,'bold'),command=insert_members)
insert_mem.pack()
delete_mem = Button(f3, text = '2.Delete A member.',font =
('arial', 20 ,'bold'),command=delete_members)
delete_mem.pack()
search_mem = Button(f3, text= '3. Search Member.',font = ('arial',
20 ,'bold'),command=search_members)
search_mem.pack()
root.mainloop()

def book_details2():
quit1()
book_details()

f1 = Frame(root, bg='red', borderwidth=8, relief=GROOVE)


f1.pack(side=LEFT)
b1 = Button(f1, text='1.Book Details.', font=('comicsansms', 20,
'bold'),command=book_details2)
b1.pack()

b2= Button(f1, text='2. Member Details', font=('comicsansms', 20,


'bold'),command=member_details)
b2.pack()

b3 = Button(f1, text='3.Matters', font=('comicsansms', 20, 'bold'))


b3.pack()

b4 = Button(f1, text='4.Report.', font=('comicsansms', 20, 'bold'))


b4.pack()

b5 = Button(f1, text='5. Exit',command=quit1, font=('comicsansms', 20,


'bold'),)
b5.pack()

Bibliography
BOOK REFERNECES: -
Sumita Arora

WEB RESOURCES: -
python.org
 www.mysql.com
www.youtube.com
www.wikipedia.org
THANK YOU…

Made by:-

You might also like