CsFile
CsFile
Signature:
INDEX
3. SQL 07-01-2025
4. Output 07-01-2025
6. Bibliography 07-01-2025
INTRODUCTION TO TOPIC
Library Management System
This project focuses on developing a basic LMS that will assist both library staff
and patrons. The system will handle core functionalities such as:
Member Management:
o Registering new members and managing their information (name, ID, contact,
etc.)
Key Features:
User-friendly interface: Easy-to-use for both library staff and patrons.
Comprehensive book catalog: Efficient search and retrieval of book
information.
Member management: Streamlined registration and tracking of member
activities.
Borrowing and returning functionality: Seamless book issuance and return
processes.
PYTHON WORK
1.LibraryManager.py
elif choice==4:
break
else:
print("Wrong Choice......Enter Your Choice again")
x=input("Enter any key to continue")
2.Menulib.py
# important necessary modules
import Book
import Member
import issue
3.Member.py
# importing necessary modules
import mysql.connector
from datetime import date
def display():
# connecting with mysql database and making cursor
cnx=mysql.connector.connect(user='root',passwd='root',
host='localhost',
database='library')
Cursor = cnx.cursor()
query = ("SELECT * FROM Member")
Cursor.execute(query)
for (Mno, Mname, MOB, DOP, ADR) in Cursor:
print("="*50)
print("Member Code :",Mno)
print("Member Name :",Mname)
print("Mobile No. of Member :",MOB)
print("Date of Membership :",DOP)
print("Address :",ADR)
print("="*50)
#prints each record of the member table
Cursor.close() # closing the cursor
cnx.close() # closing the mysql connection
print("You have done it!!!!!!!")
def insertMember():
# connecting with mysql database and making cursor
cnx=mysql.connector.connect(user='root',passwd='root',
host='localhost',
database='Library')
Cursor = cnx.cursor()
mno = input("Enter Member Code : ")
mname = input("Enter Member Name : ")
mob = input("Enter Member Mobile No. : ")
print("Enter Date of Membership(Date, Month and Year
seperately): ")
DD = int(input("Enter Date : "))
MM = int(input("Enter Month : "))
YY = int(input("Enter Year : "))
addr =input("Enter Member Address : ")
Qry =("INSERT INTO Member VALUES (%s, %s, %s, %s,%s)")
data = (mno, mname, mob, date(YY, MM, DD), addr)
Cursor.execute(Qry, data)
# runs the query, substituting values from data tuple
# Make sure data is committed to the database
cnx.commit()
Cursor.close() # closing the cursor
cnx.close() # closing the mysql connection
print("Record Inserted............")
def deleteMember():
# connecting with mysql database and making cursor
cnx=mysql.connector.connect(user='root',passwd='root',
host='localhost',
database='Library')
Cursor = cnx.cursor()
mno = input("Enter Member Code of the Member to be
deleted from the Library : ")
Qry = ("DELETE FROM Member WHERE MNO = %s")
del_rec = (mno,)
Cursor.execute(Qry, del_rec)
#runs the query,substituting values from del_rec tuple
# Make sure data is committed to the database
cnx.commit()
Cursor.close() # closing the cursor
cnx.close() # closing the mysql connection
print (Cursor.rowcount, "Record(s) Deleted
Successfully..........")
def SearchMember():
# connecting with mysql database and making cursor
cnx=mysql.connector.connect(user='root',passwd='root',
host='localhost',
database='Library')
Cursor = cnx.cursor()
mno=input("Enter Member Code to be Searched: ")
query = ("SELECT * FROM Member where Mno = %s")
rec_srch=(mno,)
Cursor.execute(query, rec_srch)
#runs the query,substituting value from rec_srch tuple
Rec_count=0
for (Mno, Mname, MOB, DOP, ADR) in Cursor:
Rec_count += 1
print("="*50)
print("Member Code : ", Mno)
print ("Member Name : ", Mname)
print("Mobile No.of Member : ", MOB)
print ("Date of Membership : ", DOP)
print ("Address : ",ADR)
print("="*50)
#prints each record of the member table
if Rec_count%2==0:
input ("Press any key to continue")
clrscreen()
print (Rec_count, "Record(s) found")
# Make sure data is committed to the database
cnx.commit()
Cursor.close() # closing the cursor
cnx.close() # closing the mysql connection
def UpdateMemberDetails():
# connecting with mysql database and making cursor
cnx=mysql.connector.connect(user='root',
passwd='root',
host='localhost',
database='Library')
Cursor = cnx.cursor()
mno=input("Enter Member Code for the member to be
Updated: ")
query = ("SELECT * FROM Member where Mno = %s")
rec_srch=(mno,)
#runs the query,substituting value from rec_srch tuple
Cursor.execute(query, rec_srch)
for (Mno, Mname, MOB, DOP, ADR) in Cursor:
print("="*50)
print("Member Code : ", Mno)
print ("Member Name : ", Mname)
print("Mobile No.of Member : ", MOB)
print ("Date of Membership : ", DOP)
print ("Address : ",ADR)
print("="*50)
#prints each record of the member table
print("Enter new data:")
mname = input("Enter Member Name : ")
mob = input("Enter Member Mobile No. : ")
print("Enter Date of Membership (Date/Month and Year
seperately) : ")
DD = int(input("Enter Date : "))
MM = int(input("Enter Month : "))
YY = int(input("Enter Year : "))
addr = input("Enter Member Address : ")
Qry = ("UPDATE member SET Mno=%s, Mname=%s, mob=%s, \
d_o_member=%s, addr = %s WHERE Mno=%s")
data = (mno, mname, mob, date(YY, MM, DD), addr,mno)
Cursor.execute(Qry, data)
#runs the query, substituting values from data tuple
# Make sure data is committed to the database
cnx.commit()
Cursor.close() # closing the cursor
cnx.close() # closing the mysql connection
print("Record Updated............")
4.Book.py
#importing necessary modules
import mysql.connector
from datetime import date
def display():
# connecting with mysql database and making cursor
cnx = mysql.connector.connect(user='root',
password='root',
host='localhost',
database='Library')
Cursor = cnx.cursor()
query = "SELECT * FROM BookRecord"
Cursor.execute(query)
for(Bno,Bname,Author,price,publ,qty,d_o_purchase) in \
Cursor:
print("="*50)
print("Book Code :", Bno)
print("Book Name :", Bname)
print("Author of Book :", Author)
print("Price of Book :", price)
print("Publisher :", publ)
print("Total Quantity in Hand :", qty)
print("Purchased On :", d_o_purchase)
print("="*50)
#prints each record of the bookrecord table
Cursor.close() # closing the cursor
cnx.close() # closing the mysql connection
print("You have done it!!!!!!")
def insertData():
# connecting with the mysql database and making cursor
cnx = mysql.connector.connect(user='root',
password='root',
host='localhost',
database='Library')
Cursor = cnx.cursor()
bno=input("Enter Book Code: ")
bname=input("Enter Book Name: ")
Auth=input("Enter Book Author's Name: ")
price=int(input("Enter Book Price: "))
publ=input("Enter Publisher of Book: ")
qty=int(input("Enter Quantity purchased: "))
print("Enter Date of Purchase (Date/Month and Year
separately): ")
DD=int(input("Enter Date: "))
MM=int(input("Enter Month: "))
YY=int(input("Enter Year: "))
Qry = ("INSERT INTO BookRecord VALUES (%s, %s, %s, %s,
%s, %s, %s)")
data = (bno, bname,Auth,price,publ,qty,date(YY,MM,DD))
Cursor.execute(Qry, data)
# runs the query, substituting values from data tuple
# Make sure data is committed to the database
cnx.commit()
Cursor.close() # closing the cursor
cnx.close() # closing the mysql connection
print("Record Inserted............")
def deleteBook():
# connecting with mysql database and making cursor
cnx = mysql.connector.connect(user='root',
password='root',
host='localhost',
database='Library')
Cursor = cnx.cursor()
bno = input("Enter Book Code of the Book to be deleted
from the Library: ")
Qry = "DELETE FROM BookRecord WHERE BNO = %s"
del_rec = (bno,)
Cursor.execute(Qry, del_rec)
#runs the query,substituting values from del_rec tuple
# Make sure data is committed to the database
cnx.commit()
Cursor.close() # closing the cursor
cnx.close() # closing the mysql connection
print(Cursor.rowcount, "Record(s) Deleted
Successfully............")
def SearchBookRec():
#connecting with mysql database and making cursor
cnx = mysql.connector.connect(user='root',
password='root',
host='localhost',
database='Library')
Cursor = cnx.cursor()
bno = input("Enter Book No to be Searched from the
Library: ")
query = ("SELECT * FROM BookRecord where BNo = %s ")
rec_srch=(bno,)
Cursor.execute(query,rec_srch)
#runs the query,substituting value from rec_srch tuple
Rec_count=0
for(Bno,Bname,Author,price,publ,qty,d_o_purchase) in \
Cursor:
Rec_count+=1
print(" ")
print("Book Code :",Bno)
print("Book Name :",Bname)
print("Author of Book :",Author)
print("Price of Book :",price)
print("Publisher :",publ)
print("Total Quantity in Hand :",qty)
print("Purchased On :",d_o_purchase)
print(" ")
# prints each record of the bookrecord table
if Rec_count>=0:
input("Press any key to continue")
print(Rec_count,"Record(s) found")
# Make sure data is committed to the database
cnx.commit()
Cursor.close() # closing the cursor
cnx.close() # closing the mysql connection
def UpdateBook():
# connecting with mysql database and making cursor
cnx = mysql.connector.connect(user='root',
password='root',
host='localhost',
database='Library')
Cursor = cnx.cursor()
bno=input("Enter Book Code of the Book to be Updated
from the Library : ")
query = ("SELECT * FROM BookRecord where BNo = %s ")
rec_srch=(bno,)
Cursor.execute(query,rec_srch)
#runs the query,substituting value from rec_srch tuple
for(Bno,Bname,Author,price,publisher,qty,\
d_o_purchase) in Cursor:
print("="*50)
print("Book Code : ", Bno)
print ("Book Name : ", Bname)
print("Author : ", Author)
print ("Price : ", price)
print ("publisher : ",publisher)
print("quantity :",qty)
print("date of purchase :",d_o_purchase)
print("="*50)
# prints each record of the bookrecord table
print ("Enter new data: ")
bname=input("Enter Book Name: ")
Auth=input("Enter Book Author's Name:")
price=int(input("Enter Book Price: "))
publ=input("Enter Publisher of Book: ")
qty=int(input("Enter Quantity purchased: "))
print("Enter Date of Purchase Date,Month and Year
seperately: ")
DD=int(input("Enter Date: "))
MM=int(input("Enter Month: "))
YY=int(input("Enter Year: "))
Qry = ("update Bookrecord set Bname=%s, Author=\
%s,price=%s,publisher=%s,qty=%s,\
d_o_purchase=%s WHERE Bno=%s")
data = (bname, Auth, price, publ,qty, date(YY, MM,
DD),bno)
Cursor.execute(Qry, data)
#runs the query, substituting values from data tuple
# Make sure data is committed to the database
cnx.commit()
Cursor.close() # closing the cursor
cnx.close() # closing the mysql connection
print (Cursor.rowcount, "Record(s) Updated
Successfully........")
5.issue.py
# importing necessary modules
import mysql.connector
from datetime import date
def ShowIssuedBooks():
# connecting with mysql database and making cursor
cnx = mysql.connector.connect(user='root',
password='root',
host='localhost',
database='Library')
Cursor = cnx.cursor()
query = ("SELECT I.bno, B.bname, I.mno, M.mname,\
d_o_issue, d_o_ret FROM bookRecord B,\
issue I,member M where B.bno=I.bno and \
I.mno=M.mno")
Cursor.execute(query)“””query for the records where
Book code and Member code are
same”””
for (Bno, Bname, Mno, Mname, doi, dor) in Cursor:
print(" ")
print("Book Code :", Bno)
print("Book Name :", Bname)
print("Member Code :", Mno)
print("Member Name :", Mname)
print("Date of issue :", doi)
print("Date of return :", dor)
print(" ")
“””prints each record of the issue table along
with Bname column from bookrecord, Mname column
from member”””
Cursor.close() # closing the cursor
cnx.close() # closing the mysql connection
print("You have done it!!!!!!!")
def issueBook():
# connecting with mysql database and making cursor
cnx = mysql.connector.connect(user='root',
password='root',
host='localhost',
database='Library')
Cursor = cnx.cursor()
bno = input("Enter Book Code to issue : ")
mno = input("Enter Member Code : ")
print("Enter Date of Issue (Date/Month and Year
separately): ")
DD = int(input("Enter Date : "))
MM = int(input("Enter Month : "))
YY=int(input("Enter Year : "))
Qry = ("INSERT INTO issue (bno,mno,d_o_issue) VALUES
(%s, %s, %s)")
data = (bno,mno,date(YY,MM,DD))
Cursor.execute(Qry,data)
#runs the query, substituting values from data tuple
cnx.commit()
Cursor.close() # closing the cursor
cnx.close() # closing the mysql connection
print("Record Inserted............")
def returnBook():
# connecting with the mysql database and making cursor
cnx = mysql.connector.connect(user='root',
password='root',
host='localhost',
database='Library')
Cursor = cnx.cursor()
bno = input("Enter Book Code of Book to be returned to
the Library : ")
Mno = input("Enter Member Code of Member who is
returning Book : ")
retDate = date.today()
Qry =("Update Issue set d_o_ret=%s WHERE BNO = %s
and Mno = %s")
rec =(retDate,bno,Mno)
Cursor.execute(Qry,rec)
#runs the query, substituting values from rec tuple
# Make sure data is committed to the database
cnx.commit()
Cursor.close() # closing the cursor
cnx.close() # closing the mysql connection
print(Cursor.rowcount,"Record(s) Updated
Successfully............")
SQL
OUTPUTS
Output 1 ->
(A ) To Add Book Record
(
B) Display of Issued Book Records
1. LibraryManager.py
Overview: This file acts as the main interface for the library management system. It provides a menu-
driven console interface for users to navigate different sections of the system, such as managing
books, members, and issuing or returning books.
Functionality:
Main Menu: Presents a menu to the user with options to manage books, members, or handle
book issues/returns.
Input Handling: Continuously prompts the user to enter their choice and invokes
corresponding functions from other modules (Menulib).
Navigation: Based on user input, the program directs to the specific functions for book
management (MenuBook), member management (MenuMember), or issue/return
operations (MenuIssueReturn).
Purpose: This file serves as the central hub, coordinating between different parts of the system,
ensuring users can easily access various functionalities.
2. Menulib.py
Overview: Menulib.py is responsible for defining the menus related to book management,
member management, and book issue/return operations. It structures the user’s interactions within
these areas.
Functionality:
MenuBook: Presents options for book-related actions such as adding, displaying, searching,
deleting, and updating book records.
MenuMember: Offers options to manage library members, including adding new members,
viewing member details, searching for members, and updating member information.
MenuIssueReturn: Provides options for issuing books to members, returning books, and
viewing issued books.
Purpose: This module organizes the user interface into manageable segments for different operations,
making it easier for users to interact with specific aspects of the library system.
3. Member.py
Overview: Member.py handles all operations related to library members. This includes CRUD
operations (Create, Read, Update, Delete) for member records in the database.
Functionality:
Adding Members: Allows users to input new member information and stores it in the
database.
Displaying Members: Retrieves and shows all member records from the database.
Searching Members: Provides functionality to search for specific members using their unique
member code.
Deleting Members: Facilitates the removal of a member’s record from the database.
Updating Member Details: Enables updates to existing member information, such as contact
details or address.
Purpose: This module is essential for maintaining an up-to-date and accurate member database,
ensuring that the library can manage its members effectively.
4. Book.py
Overview: Book.py focuses on the management of books within the library. Similar to Member.py,
it provides CRUD operations for books.
Functionality:
Inserting New Books: Users can add new books to the library’s collection by entering details
like title, author, and publication date.
Displaying Books: Retrieves and displays all books available in the library’s database.
Searching Books: Users can search for specific books using book codes or other identifying
information.
Deleting Books: Removes a book from the library’s records.
Updating Book Information: Allows for updates to book details such as price, quantity, or
publisher.
Purpose: This module ensures the library’s book inventory is well-managed, making it easier to keep
track of available books and their details.
5. issue.py
Overview: issue.py manages the process of issuing books to members and recording their return.
It ensures that book transactions are properly tracked.
Functionality:
Issuing Books: Records the transaction when a member borrows a book, including the issue
date.
Returning Books: Updates the system when a member returns a book, ensuring accurate
tracking of which books are currently borrowed.
Displaying Issued Books: Lists all books that are currently issued, along with details such as the
member who borrowed them and the dates of issue and expected return
Purpose: This module plays a crucial role in monitoring the circulation of books within the library,
preventing losses and ensuring timely returns.
Database Interaction
Each module interacts with a MySQL database to perform its operations. The database likely contains
tables for books, members, and issued books, with each table storing relevant details:
Books Table: Stores information like book ID, title, author, price, publisher, and quantity.
Members Table: Contains member ID, name, contact details, and membership date.
Issues Table: Tracks which books have been issued to which members, along with issue and
return dates.