0% found this document useful (0 votes)
11 views15 pages

Library Management Document PDF

The document outlines a library management system project aimed at efficiently managing library resources through a user-friendly software interface. It details the project's objectives, required hardware and software, functions, modules, and includes source code for various operations such as adding, displaying, searching, deleting, and updating book records. Additionally, it provides a bibliography for further reference.

Uploaded by

Aryan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views15 pages

Library Management Document PDF

The document outlines a library management system project aimed at efficiently managing library resources through a user-friendly software interface. It details the project's objectives, required hardware and software, functions, modules, and includes source code for various operations such as adding, displaying, searching, deleting, and updating book records. Additionally, it provides a bibliography for further reference.

Uploaded by

Aryan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

INDEX

SNo. TOPIC PAGE NO.

1. OBJECTIVE OF THE
PROJECT
2. HARDWARE
REQUIREMENTS
3. SOFTWARE
REQUIREMENTS
4. FUNCTIONS

5. MODULES

6. SOURCE CODE

7. OUTPUT

8. BIBLIOGRAPHY
OBJECTIVE OF THE PROJECT:
The main objective of a library management system project is to
create a software that can manage the details of books in a library. The
software is designed to be used by the library staff to keep track of the
books. The project aims to provide an efficient and user-friendly way to
manage the library’s resources.

2
FUNCTION:
A function is a block of code, which only runs when it is called.
You can pass data, known as parameters, into a function. A
function can return data as a result.

1. Built-in functions: These predefined functions are always


available for use. Eg:- len(),int() etc.

2. Functions defined in modules: These are predefined


functions available in specific modules and can be used
only when that module is imported. Eg: random.randint()
gives a random integer value in a given interval. This is
available in the random module.
3. User defined functions: the user defines these functions.

Functions used in this project:

Built-in function User-defined functions


 cursor()  insertbook()
 execute()  displaybook()
 print()  searchbook()
 int()  deletebook()
 fetchall()  updatebook()
 commit()
 connect()

3
MODULES:
A Python module is a file containing Python definitions and
statements. A module can define functions, classes, and
variables.
Modules used in this project:
Mysql.connector: This method sets up a connection, establishing
a session with the MySQL server. If no arguments are given, it
uses the already configured or default values. A connection with
the MySQL server can be established using either
the mysql.connector.connect() method or
the mysql.connector.MySQLConnection()

4
ABOUT THIS PROJECT:
This project aims at creating a python program on ‘library
management’. The program first asks the customer to add the
new books details like book name, author name etc. It gives
option to display all the available books in the library. User can
check the availability of the book using this program. It allows
deleting the books, which are not available. If the user needs to
change the details of the book stored, they can update the
details using the update function.

5
SOURCE CODE:
import mysql.connector

mydb=mysql.connector.connect(host='localhost',user='root',pass
word='Tiger')
mycursor=mydb.cursor()

mycursor.execute("CREATE DATABASE IF NOT EXISTS


LIBRARY")
mycursor.execute("USE LIBRARY")
rec="create table IF NOT EXISTS Book(bno INTEGER PRIMARY
KEY,bname VARCHAR(50) NOT NULL,bauth VARCHAR(50) not
null,bprice INTEGER NOT NULL,bqty INTEGER NOT NULL)"
mycursor.execute(rec)

mycon=mysql.connector.connect(host='localhost',user='root',pas
sword='Tiger',database='LIBRARY')
mycur=mycon.cursor()

# function to insert book record


def insertbook():
bno=int(input("Enter Book Code:"))
bname=input("Enter Book Name:")
bauth=input("Enter Book Author:")
bprice=int(input("Enter Book Price:"))
bqty=int(input("Enter Book Quantity:"))

qry="INSERT INTO book VALUES(%s,%s,%s,%s,%s)"


data=(bno,bname,bauth,bprice,bqty)
6
mycur.execute(qry,data)
mycon.commit()
print("\t\tRecord ADDED successfuly...")

# Function to display book record


def displaybook():
qry="SELECT * FROM book"
mycur.execute(qry)
data=mycur.fetchall()
count=mycur.rowcount
print("\t\t Total Book Records.........:",count,"\n")

for (bno,bname,bauth,bprice,bqty) in data:


print("Book Code:\t",bno)
print("Book Name:\t",bname)
print("Book Author:\t",bauth)
print("Book Price:\t",bprice)
print("Book Quantity:\t",bqty)
print(".................................")

# function to search book record


def searchbook():
bno=int(input("Enter book number to be searched...:"))
qry="SELECT * FROM book WHERE bno=%s"
rec=(bno,)
mycur.execute(qry,rec)
data=mycur.fetchall()
count=mycur.rowcount
if count!=0:
print("\t\t Book Records found.........:\n")
for (bno,bname,bauth,bprice,bqty) in data:
print("Book Code:\t",bno)
print("Book Name:\t",bname)
7
print("Book Author:\t",bauth)
print("Book Price:\t",bprice)
print("Book Quantity:\t",bqty)
print(".................................")

else:
print("\t\t\t Record NOT found..!!!")

# function to delete book record


def deletebook():
bno=int(input("Enter book number to be deleted...:"))
qry="SELECT * FROM book WHERE bno=%s"
rec=(bno,)
mycur.execute(qry,rec)
data=mycur.fetchall()
count=mycur.rowcount

if count!=0:
print("\t\t Book Records found.........:\n")
for (bno,bname,bauth,bprice,bqty) in data:
print("Book Code:\t",bno)
print("Book Name:\t",bname)
print("Book Author:\t",bauth)
print("Book Price:\t",bprice)
print("Book Quantity:\t",bqty)
print(".................................")

opt=input("Are you SURE to DELETE above record


(Y/N)...:")
if opt=="Y" or opt=="y" :
qry= "DELETE FROM book WHERE bno=%s"
rec=(bno,)
mycur.execute(qry,rec)
8
print("\n\t\tRecord deleted Successfully...... ")
mycon.commit()

else:
print("\t\t\t Record NOT found..!!!")

# function to update book record


def updatebook():
bno=int(input("Enter book number to be updated...:"))
qry="SELECT * FROM book WHERE bno=%s"
rec=(bno,)
mycur.execute(qry,rec)
data=mycur.fetchall()
count=mycur.rowcount

if count!=0:
print("\t\t Book Records found.........:\n")
for (bno,bname,bauth,bprice,bqty) in data:
print("Book Code:\t",bno)
print("Book Name:\t",bname)
print("Book Author:\t",bauth)
print("Book Price:\t",bprice)
print("Book Quantity:\t",bqty)
print(".................................")

opt=input("Are you SURE to UPDATE above record


(Y/N)...:")
if opt=="Y" or opt=="y" :
print ("\n\t\tEnter new Data....")
bname=input("Enter New Book Name:")
bauth=input("Enter New Book Author:")
bprice=int(input("Enter New Book Price:"))
bqty=int(input("Enter New Book Quantity:"))
9
qry= ("UPDATE book SET
bname=%s,bauth=%s,bprice=%s,bqty=%s WHERE bno=%s")
rec=(bname,bauth,bprice,bqty,bno)
mycur.execute(qry,rec)
print("\n\t\tRecord Updated Successfully...... ")
mycon.commit()

else:
print("\t\t\t Record NOT found..!!!")

# code to display menu


while True :
print("\n\t\t LIBRARY BOOK RECORD MANAGEMENT\n")
print("==================================")
print("\t\t 1. Add New Book record")
print("\t\t 2. Display Book record")
print("\t\t 3. Search Book record")
print("\t\t 4. Delete Book record")
print("\t\t 5. Update Book record")
print("\t\t 6. EXIT")
print("==================================")
choice=int(input("Enter choice 1-6:"))
if choice==1:
insertbook() # function called for inserting book
elif choice==2:
displaybook() # function called for displaying records of
book(s)
elif choice==3:
searchbook() # function called for searching book
elif choice==4:
deletebook() # function called for deleting book
elif choice==5:
updatebook() # function called for updating book record
10
elif choice==6:
mycon.close()
print("\n Thanks have a nice day.........")
break
else :
print("\t!!!wrong choice... please enter choice 1-6:")

11
OUTPUT

12
13
14
BIBLIOGRAPHY:
1. Book – Python by Sumita Arora
2. www.python.org
3. https://www.geeksforgeeks.org

15

You might also like