Library Mange Ment
Library Mange Ment
Library Mange Ment
KENDRIYA
VIDYALAYA NO.1,
AFS PUNE-32
Student Details
Name: -
Class: - 12th C
Roll no: -
Session: -
Date:
Signature:
Acknowledgement
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()
if ch == 2:
x = int(input("Enter The book id : "))
qry = "select * from books where bookid = {};".format(x)
cursor.execute(qry)
myresult = cursor.fetchall()
def book_delete():
cursor = con.cursor()
sql = "select * from books ;"
cursor.execute(sql)
myresult = cursor.fetchall()
Members handler
import mysql.connector as ms
from tabulate import tabulate
mydb = ms.connect(
host = 'localhost',
user = 'root',
password = 'Oppocharger@123',
database = 'library'
)
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))
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():
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()
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")
def quit1():
root.quit()
def book_details():
root = Tk()
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()
Bibliography
BOOK REFERNECES: -
Sumita Arora
WEB RESOURCES: -
python.org
www.mysql.com
www.youtube.com
www.wikipedia.org
THANK YOU…
Made by:-