CS_Project_z
CS_Project_z
CS_Project_z
COMPUTER SCIENCE
PROJECT
LIBRARY MANAGEMENT SYSTEM
Abstract
This project presents the development of a Library Management System to streamline library
operations and provide a user-friendly solution for managing books, members, and
borrowing processes.
_____________________ ______________________
Signature of Principal Signature of External Examiner
_____________________
Signature of Subject Teacher
1|P a g e
DECLARATION
I, Md. Zunaid Khan, a student of class XII, hereby declare that I have
completed my project to the best of mine ability and knowledge. I have
taken a lot of effort to complete this task successfully.
______________________
Signature of the Student
2|P a g e
ACKNOWLEDGEMENT
First and above all, I praise God, the almighty for providing me this
opportunity and granting me the capability to proceed successfully. This
piece of work will never be accomplished without His blessings. Then I
would like to express my greatest appreciation to everyone who have
helped and supported me throughout the project. I am thankful to my
Computer Science Teacher, Mrs. Debosree Bhattacharjee for her ongoing
support during the project. Her advice and encouragement had a huge
role to finalize this project report. I wish to thank my parents as well for
their support and encouragement without which I could not have
completed this project in the limited timeframe. In the end, I want to thank
my friends who displayed appreciation for our work and motivated me to
continue my work.
3|P a g e
INDEX
PAGE
SL NO. TOPIC
NO.
1. INTRODUCTION 5
2. OPERATIONS 5-6
3. SYSTEM DESIGN 7
5. SQL QUERIES 16 - 17
6. DEMONSTRATIONS 17 – 20
7. CONCLUSION 20
8. BIBLIOGRAPHY 21
4|P a g e
1 INTRODUCTION
Purpose:
The purpose of this project is to ease the management of a Library. It
uses Python programming with SQL connectivity concepts to make the
work easier and support the smooth functioning of a Library. This is
Python Projects on Library Management system, which provided a lot of
facility to their member to manage their activity easily. The objective and
scope of my Project Library Management system is to record the details
various activities of member. It will simplify the task and reduce the
paper work.
2 OPERATIONS
5|P a g e
d. Price
e. Quantity
4. View all books - We can know all the details of an issued book
using Issue ID.
5. View all members - We can view list of all the books present in the
library.
6. View all issued books - We can view list of all the members
registered with the library.
6|P a g e
3 SYSTEM DESIGN
–
LIBRARY MANAGEMENT
SYSTEM
edit_books() books
members
edit_members()
issuedbooks
issbk()
view_books()
view_members()
view_issbk()
menu()
7|P a g e
4 PYTHON SOURCE CODE
# Books Dataset
def edit_books():
flag = True
c = sqlc.connect(user='root', host='localhost',
password='zunaid1234', database='library')
mc = c.cursor()
while flag:
bname = input("Enter the book name: ")
ath = input("Enter the author: ")
pb = input("Enter the publisher: ")
prc = float(input("Enter the price: "))
qty = int(input("Enter the quantity: "))
if cr in records:
mc.execute(
"UPDATE books SET `Price` = %s, `Quantity` = %s
WHERE `Book Name` = %s AND `Author` = %s AND `Publisher` = %s",
(prc, qty, bname, ath, pb)
)
else:
mc.execute("SELECT `Book ID` FROM books")
records = [r[0] for r in mc.fetchall()]
while True:
fc = random.choice(string.ascii_uppercase)
digits = ''.join(random.choices(string.digits, k=3))
bid = fc + digits
8|P a g e
if bid not in records:
break
mc.execute(
"INSERT INTO books (`Book ID`, `Book Name`,
`Author`, `Publisher`, `Price`, `Quantity`) VALUES (%s, %s, %s, %s,
%s, %s)",
(bid, bname, ath, pb, prc, qty)
)
print(f"Book ID assigned: {bid}")
c.close()
# Members Dataset
def edit_members():
flag = True
c = sqlc.connect(user='root', host='localhost',
password='zunaid1234', database='library')
mc = c.cursor()
while flag:
mc.execute("SELECT `Member ID`, `Member Name`, `Telefone`,
`E-mail`, `Address` FROM members")
members = mc.fetchall()
act = input("What do you want to do - Edit(E)/Add(A) or
Remove(R)? ")
if act.lower() == 'e' or act.lower() == 'a':
try:
mid = int(input("Enter the member ID: "))
except ValueError:
mnm = input("Enter the member name: ")
tel = input("Enter the telephone number: ")
em = input("Enter the email ID: ")
ads = input("Enter the address: ")
9|P a g e
if any(mnm == record[1] and (tel == record[2] or em
== record[3] or ads == record[4]) for record in members):
mc.execute(
"UPDATE members SET `Telefone` = %s, `E-
mail` = %s, `Address` = %s WHERE `Member Name` = %s",
(tel, em, ads, mnm)
)
else:
while True:
digits =
''.join(random.choices(string.digits, k=3))
if digits not in [record[0] for record in
members]:
break
mc.execute("INSERT INTO members (`Member ID`,
`Member Name`, `Telefone`, `E-mail`, `Address`) VALUES (%s, %s, %s,
%s, %s)", (digits, mnm, tel, em, ads))
print(f"Member ID assigned: {digits}")
else:
mnm2 = input("Enter the member name: ")
tel2 = input("Enter the telephone number: ")
em2 = input("Enter the email ID: ")
ads2 = input("Enter the address: ")
10 | P a g e
if telv or emv:
if (idv == record[0] and nmv == record[1] and (telv
== record[2] or emv == record[3]) for record in members):
mc.execute("DELETE FROM members WHERE `Member
ID` = %s", (idv, ))
print(f"Removed member with ID: {idv}")
else:
print("Invalid data... No member with such
dataset exists.")
else:
print("Error! Either the telephone or email ID is
required for removal of a member.")
else:
print('Invalid Input...')
c.close()
def issbk():
flag = True
c = sqlc.connect(user='root', host='localhost',
password='zunaid1234', database='library')
mc = c.cursor()
while flag:
act = input("Do you want to return or issue? (r/i)
").strip().lower()
if act == 'i':
mid = int(input("Enter the Member ID: "))
mnm = input("Enter the name of the member: ")
mc.execute("SELECT `Member ID`, `Member Name` FROM
members")
record = mc.fetchall()
cr = (mid, mnm)
11 | P a g e
if cr in record:
bid = input("Enter the book ID: ")
bnm = input("Enter the book name: ")
mc.execute("SELECT `Book ID`, `Book Name` FROM
books")
rec = mc.fetchall()
crr = (bid, bnm)
if crr in rec:
mc.execute("SELECT `Member ID`, `Member Name`,
`Book ID`, `Book Name` FROM issuedbooks")
ccc = mc.fetchall()
12 | P a g e
print("Invalid credentials...")
if cr in record:
bid = input("Enter the book ID: ")
bnm = input("Enter the book name: ")
mc.execute("SELECT `Book ID`, `Book Name` FROM
books")
rec = mc.fetchall()
crr = (bid, bnm)
if crr in rec:
qty = int(input("Enter the quantity of returned
books: "))
mc.execute("SELECT `Member ID`, `Member Name`,
`Book ID`, `Book Name` FROM issuedbooks")
cii = mc.fetchall()
13 | P a g e
print("THIS MEMBER HAVE NO SUCH ISSUED
BOOKS...")
else:
print("NO SUCH BOOK EXISTS...")
else:
print("NO SUCH MEMBER EXISTS...")
else:
print("PLEASE ENTER A VALID INPUT...")
if choice == 'n':
flag = False
c.close()
def viewbooks():
c = sqlc.connect(user='root', host='localhost',
password='zunaid1234', database='library')
mc = c.cursor()
mc.execute("SELECT * FROM books")
records = mc.fetchall()
for record in records:
print(record)
c.close()
def viewmembers():
c = sqlc.connect(user='root', host='localhost',
password='zunaid1234', database='library')
mc = c.cursor()
mc.execute("SELECT * FROM members")
recs = mc.fetchall()
for rec in recs:
print(rec)
14 | P a g e
c.close()
def viewissbk():
c = sqlc.connect(user='root', host='localhost',
password='zunaid1234', database='library')
mc = c.cursor()
mc.execute("SELECT issuedbooks.`Member ID`, issuedbooks.`Member
Name`, members.`Telefone`, members.`E-mail`, members.`Address`,
issuedbooks.`Book ID`, issuedbooks.`Book Name`, books.`Publisher`,
issuedbooks.`Quantity Issued`, issuedbooks.`Issue Date` FROM
issuedbooks, members, books WHERE (issuedbooks.`Member ID` =
members.`Member ID`) AND (issuedbooks.`Book ID` = books.`Book ID`)")
recs = mc.fetchall()
for rec in recs:
mid, mnm, tel, email, addr, bid, bnm, pub, qty, issue_date =
rec
formatted_date = issue_date.strftime('%d-%b-%Y') if
isinstance(issue_date, datetime) else issue_date
print(f"Member ID: {mid}, Member Name: {mnm}, Telefone:
{tel}, E-mail: {email}, Address: {addr}, Book ID: {bid}, Book Name:
{bnm}, Publisher: {pub}, Quantity Issued: {qty}, Issue Date:
{formatted_date}")
c.close()
def menu():
while True:
print('''Which of the following tasks do you want to do?
1. Edit books database
2. Edit members database
3. Edit issuedbooks database
4. View all books
5. View all members
6. View all issuedbooks
7. Exit''')
choice = int(input("Enter an integer based on the above
numbering: "))
15 | P a g e
if choice == 1:
edit_books()
elif choice == 2:
edit_members()
elif choice == 3:
issbk()
elif choice == 4:
viewbooks()
elif choice == 5:
viewmembers()
elif choice == 6:
viewissbk()
elif choice == 7:
break
else:
print("Invalid choice! Please enter a valid input...")
menu()
5 SQL QUERIES
16 | P a g e
-> `Quantity Issued` INTEGER NOT NULL,
-> PRIMARY KEY (`Member ID`, `Book ID`));
6 DEMONSTRATION
17 | P a g e
3. Editing the members table (Adding a new member):
18 | P a g e
5. Issuing a book:
19 | P a g e
9. Exiting the program:
7 CONCLUSION
20 | P a g e
BIBLIOGRAPHY
21 | P a g e