libray management pawan final
libray management pawan final
2
CERTIFICATE
This is to certify that PAWAN KUMAR of class XII-B has
successfully completed the INFORMATICS PRACTICES
project on the topic of LIBRARY MANAGEMENT under the
guidance of MRS. SANGEETA MAHOPATRA mam
during the academic year 2024-2025.
2 YYY
2
1
2 YYY
Acknowledgement
I would like to express my special thanks of gratitude
to my teacher MRS SANGEETA MAHOPATRA mam as
well as our principal MRS SANGEETA SHARMA mam
who gave me the golden opportunity to do this project
of informatics practices which also helped me in doing
a lot of research and I came to know new things about
it. without there help, guidance and support it would
have been impossible to complete this project.
2 YYY
2
2
2 YYY
PROJECT ON
LIBRARY MANAGEMENT
2024-25
2 YYY
2
3
2 YYY
INDEX
SNO. PARTICULARS PAEG NO.
1 PROJECT ANALYSIS 5
3 DETAILED DESCRIPTION 9
6 BIBLIOGRAPHY 23
7 REMARS 24
2
2 YYY
4
2 YYY
PROJECT ANAYLSIS
Our application program is especially
Designed for the sardar Patel vidya Niketan named
“READING COMMUNITY”
2 YYY
5
2 YYY
FUNCTIONS AND MODULES
MODULES :
#import.mysql.connector:
2
2
YYY 6
2 YYY
FUNCTIONS :
connect () :
this function establishes connection between python &
mysql .
cursor():
it is a special control structure that facilitates the row
by row processing of recordes in the result set.
<cursor object>=<connection object>.cursor ()
execute ():
this function is used to execute the sql query and
retrieve records using python.
the syntax is:
<cursor object>.execute(sql query string)
def () :
a function is a block of code which only runs when it is
called.
2
2 YYY
7
2 YYY
fetchall ():
this function will return all the rows from the result set
in the form of a tuple containing the records.
fetchone():
this function will return one row from the result set in
the form of the tuple containing the records.
commit():
this function provides change in the database
physically.
2
2 YYY
8
2 YYY
DETAILED DESCRIPTION
# our project has three MySQL tables. These are: -
1. Books management
2. Members Management
3. Issue/Return
2 YYY
2
9
2 YYY
SOURCE CODE
import mysql.connector
# Database connection
try:
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="PAWAN@123kumar",
database="spvn_library"
if mydb.is_connected():
else:
print(f"Error: {err}")
exit(1)
mycursor = mydb.cursor()
10
mycursor.execute("CREATE DATABASE IF NOT EXISTS spvn_library")
mycursor.execute("""
bname VARCHAR(20),
author VARCHAR(20),
publisher VARCHAR(50),
price INT(10),
qty INT(50),
d_of_purchased DATE
)""")
mycursor.execute("""
mname CHAR(20),
mobile INT(10),
addr VARCHAR(50),
d_of_mship DATE
)""")
mycursor.execute("""
issue_no VARCHAR(5),
bno VARCHAR(5),
mno VARCHAR(5),
d_of_issue DATE,
d_of_return DATE
)""")
def addbook():
L = []
11
bno = input("Enter book code: ")
L.append(bno)
L.append(bname)
L.append(author)
L.append(pub)
L.append(price)
L.append(qty)
L.append(d_of_pur)
sql = "INSERT INTO book_record (bno, bname, author, publisher, price, qty, d_of_purchased)
VALUES (%s, %s, %s, %s, %s, %s, %s)"
mycursor.execute(sql, ab)
mydb.commit()
def display():
rows = mycursor.fetchall()
for x in rows:
print(x)
def removebook():
12
bno = input("Enter book ISBN code to delete from the SPVN Library: ")
mydb.commit()
def SearchBookRec():
bno = input("Enter book code to search from the SPVN Library: ")
mycursor.execute(query, (bno,))
data = mycursor.fetchall()
if data:
print(data)
return True
else:
return False
def UpdateBook():
mycursor.execute(query, (bno,))
data = mycursor.fetchall()
if data:
13
# Corrected column name typo
mydb.commit()
else:
def insertMember():
qry = "INSERT INTO member (mno, mname, mobile, addr, d_of_mship) VALUES (%s, %s, %s, %s,
%s)"
mydb.commit()
def displaymem():
rows = mycursor.fetchall()
for x in rows:
print(x)
14
def deleteMember():
mycursor.execute(qry, (mno,))
mydb.commit()
def SearchMember():
mname = input("Enter Member name to search from the SPVN Library: ")
mycursor.execute(query, (mname,))
data = mycursor.fetchall()
if data:
print(data)
return True
else:
return False
def issuebook():
qry = "INSERT INTO issue (issue_no, mno, bno, d_of_issue, d_of_return) VALUES (%s, %s, %s, %s,
%s)"
15
mydb.commit()
def ShowIssuedBooks():
rows = mycursor.fetchall()
for x in rows:
print(x)
def returnbook():
retDate = date.today()
mydb.commit()
def spvn_library1():
while True:
print("4. Exit")
16
if userinput == 1:
while True:
if choice == 1:
addbook()
elif choice == 2:
display()
elif choice == 3:
SearchBookRec()
elif choice == 4:
removebook()
elif choice == 5:
UpdateBook()
elif choice == 6:
break
else:
elif userinput == 2:
while True:
17
print("3. Search Member Record")
if choice == 1:
insertMember()
elif choice == 2:
displaymem()
elif choice == 3:
SearchMember()
elif choice == 4:
deleteMember()
elif choice == 5:
break
else:
elif userinput == 3:
while True:
if choice == 1:
issuebook()
elif choice == 2:
ShowIssuedBooks()
18
elif choice == 3:
returnbook()
elif choice == 4:
break
else:
elif userinput == 4:
mycursor.close()
mydb.close()
break
else:
spvn_library1()
2 YYY
2
19
2 YYY
Q
OUTPUT SCREENS
m
20
21
22
2 YYY
2
2 YYY
BIBLIOGRAPHY
TO develop this project many references were
used :
2 YYY
2
23
2 YYY
REMARKS
2 YYY
2
24