0% found this document useful (0 votes)
33 views27 pages

Library Mangement-2

The document is a project report for a Library Management System created using Python and MySQL. It includes sections for analysis, design, Python code, outputs, and bibliography. The analysis section describes the MySQL and Python modules used. The design section includes the front-end menu map and back-end database script. The Python code section shows functions for displaying books, issuing books, returning books, adding books, deleting books, and viewing issued/returned records.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views27 pages

Library Mangement-2

The document is a project report for a Library Management System created using Python and MySQL. It includes sections for analysis, design, Python code, outputs, and bibliography. The analysis section describes the MySQL and Python modules used. The design section includes the front-end menu map and back-end database script. The Python code section shows functions for displaying books, issuing books, returning books, adding books, deleting books, and viewing issued/returned records.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

PMSHRI KENDRIYA VIDYALAYA KANPUR CANTT

(SHIFT-I)

COMPUTER SCIENCE PROJECT


SESSION 2023-24

(FOR CBSE AISSCE - 2024)

LIBRARY MANAGEMENT
UNDER GUIDANCE OF : PREPARED BY :

MS. JAYATI NAME :


PGT (COMPUTER SC.) CLASS :
ROLL NO. :
CERTIFICATE

This is to certify that this project report “BANK MANAGEMENT


SYSTEM” is a record of bonafide work carried out by
____________________________________________of class XII during the academic
year 2023 – 24 submitted for ALL INDIA SENIOR SCHOOL
CERTIFICATE EXAMINATION (AISSCE)– 2024 in partial fulfilment
of the requirements in COMPUTER SCIENCE prescribed by CBSE in
the school KENDRIYA VIDYALAYAKANPUR CANTT, KANPUR.
DATE:

INTERNAL EXAMINER EXTERNAL EXAMINER

PRINCIPAL
DECLARATION

We hereby declare that the project entitled “LBRARY


MANAGEMENT”, submitted to KENDRIYA VIDYALAYA, KANPUR
CANTT, for the subject of COMPUTER SCIENCE, under the guidance
of Miss Jayati, PGT Comp. Sc. , is a record of original work done by
us.

We further declare that this project record or any part of this has not
been submitted elsewhere for any other class.
ACKNOWLEDGEMENT
First and foremost, I praise and adore god almighty with gratitude, from
the depth of my heart who has been as unfailing source of strength,
comfort and inspiration in the completion of this project work also who
was the input of this project.

I wish to express my gratitude to Mr. Sompal, Principal, Kendriya


Vidyalaya, Kanpur Cantt, who has provided us with a well equipped
computer lab.

I wish to express my deep & profound sense of gratitude to my


Computer Sc. teacher Ms. Jayati Ma’am for her guidance, valuable
support and encouragement towards producing a successful project.

__________________
INDEX
1. ANALYSIS
2. DESIGN
3. PYTHON CODE
4. OUTPUTS
5. BIBLIOGRAPHY
ANALYSIS
MODULES USED:
mysql.connector

Functions used:
1. connect() :establishes connection between
python and mysql
2. cursor() :cursor object is used to give
commands to sql through python.
3. exexute() :used by cursor object to execute
sql queries using python.
4. def() :used to define user-defined functions.
5. fetchone() :used to fetch only 1 record.
6. fetchall() :used to fetch all records.
7. commit() :used to cause changes in the
database permanently.
Front-end of Project : Python

About Python
Python can be easy to pick up whether you're a first time programmer or
you're experienced with other languages.
User Friendly & Easy to Learn
The community hosts conferences and meetups, collaborates on code,
and much more. Python's documentation will help you along the way,
and the mailing lists will keep you in touch.
Applications
The Python Package Index (PyPI) hosts thousands of third-party
modules for Python. Both Python's standard library and the community-
contributed modules allow for endless possibilities.
Open-source
Python is developed under an OSI-approved open source license,
making it freely usable and distributable, even for commercial use.
Python's license is administered by the Python Software Foundation.

Back-end of Project: MySQL


DESIGN
FRONT-END
MENU MAP

LIBRARY MANAGEMENT
1. Display Books
2. Issue a Book
3. Return Book
4. Add a book
5. Delete a Book
6. Issued Books
7. Returned Books
8. Exit
BACK END
DATABASE SCRIPT
DROP DATABASE LIBRARY;

CREATE DATABASE LIBRARY;

USE LIBRARY;

CREATE TABLE BOOKS

(BCODE INT NOT NULL PRIMARY KEY,

BNAME VARCHAR(20) NOT NULL,

AUTHOR VARCHAR(21) NOT NULL,

AMT INT);

CREATE TABLE ISSUE

(SR_No INT AUTO_INCREMENT PRIMARY KEY,

BORROWER_ID INT NOT NULL,

INAME VARCHAR(21) NOT NULL,

BNAME VARCHAR(21) NOT NULL,

BCODE INT NOT NULL,

IDATE DATE NOT NULL,

STATUS VARCHAR(8) NOT NULL DEFAULT('Pending'));

CREATE TABLE BRETURN

(SR_No int auto_increment primary key,

BORROWER_ID INT NOT NULL,

RNAME VARCHAR(21) NOT NULL,

BNAME VARCHAR(21) NOT NULL,

BCODE INT NOT NULL,

RDATE DATE NOT NULL);


PYTHON CODE
#*****************************************

#LIBRARY MANAGEMENT SYSTEM

#*****************************************

#PYTHON MySQL CONNECTION

import mysql.connector as ms

mydb=ms.connect(host="localhost",user="root",passwd="root",database="LIBRARY")

#cnx=ms.connect(host="localhost",user="root",passwd="root",database="LIBRARY")

cur=mydb.cursor(buffered=True)

#*****************************************

#TO SHOW BOOKS

def books():

a="select * from BOOKS"

cur.execute(a)

d=cur.fetchall()

cur.execute("select * from BOOKS")

Books=cur.fetchall()

if len(Books)==0:

print("NO BOOK AVAILABLE...")

else:

print("CODE BOOK AUTHOR AMT")

for i in d:

print(i[0],' ',i[1],' ',i[2],' ',i[3])

#*****************************************

#TO ISSUE BOOKS

def issue():

try:

cur.execute("select * from BOOKS")


Books=cur.fetchall()

if len(Books)==0:

print("NO BOOK AVAILABLE...")

else:

books()

p=int(input("ENTER BORROWER ID:- "))

i=input("ENTER BORROWER NAME:- ")

n=input("ENTER BOOK NAME:- ")

b=int(input("ENTER BOOK CODE:- "))

d=input("ENTER DATE(yyyy-mm-dd):- " )

data=(p,i,n,b,d)

cur.execute("select * from BOOKS where BCODE=%s"%(b,))

bc=cur.fetchone()

if bc and b==bc[0]:

sql="insert into ISSUE(BORROWER_ID,INAME,BNAME,BCODE,IDATE)value(%d,'%s','%s',


%d,'%s')"%data

cur.execute(sql)

mydb.commit()

print("Book issued successfully")

sq="update BOOKS set AMT=AMT -1 where BCODE= %s"

cur.execute(sq,(b,))

mydb.commit()

elif bc and bc[0]==0:

print('BOOK IS UNAVAILABLE')

else:

print("BOOKS DOESN'T EXIST")

except ValueError:

print("Enter values properly...")


#*****************************************

#TO RETURN BOOK

def Return():

try:

p=int(input("ENTER BORROWER ID:- "))

b=int(input("ENTER BOOK CODE:- "))

bn=input("ENTER BORROWER NAME:- ")

n=input("ENTER BOOK NAME:- ")

cur.execute("select * from ISSUE")

for i in cur:

print(i)

if b==i[4] and p==i[1]:

d=input("ENTER DATE(yyyy-mm-dd)OF RETURN:- " )

sql="insert into BRETURN(BORROWER_ID,RNAME,BNAME,BCODE,RDATE) values(%d,'%s','%s',


%d,'%s')"%(p,bn,n,b,d)

cur.execute(sql)

mydb.commit()

print("Book returned successfully")

sq="update BOOKS set AMT=AMT +1 where BCODE= %s"

cur.execute(sq,(b,))

mydb.commit()

s="update ISSUE set STATUS='Returned' where BORROWER_ID=%s AND BCODE=%s"%(p,b)

cur.execute(s)

mydb.commit()

break

else:

print("This Book wasn't issued")

except ValueError:

print("Enter values properly...")


#*****************************************

#TO ADD BOOKS

def addb():

try:

c=int(input("ENTER BOOK CODE:- "))

b=input("ENTER BOOK NAME:- ")

n=input("ENTER AUTHOR's NAME:- ")

a=int(input("ENTER NUMBER OF BOOKS:- "))

cur.execute("select * from BOOKS where BCODE=%s",(c,))

existbook=cur.fetchone()

if existbook:

newn=existbook[3]+a

sql="update BOOKS set AMT=%s where BCODE=%s"%(newn,c)

cur.execute(sql)

mydb.commit()

else:

data=(c,b,n,a)

sql="insert into BOOKS(BCODE,BNAME,AUTHOR,AMT) values(%s,'%s','%s',%s)"%(data)

cur.execute(sql)

mydb.commit()

print("Book(s) added successfully")

menu()

except ValueError:

print("Enter values properly...")


#*****************************************

#TO DELETE BOOK

def deleteb():

try:

books()

bc=int(input("ENTER BOOK CODE:- "))

cur.execute("select * from BOOKS where BCODE=%s",(bc,))

book=cur.fetchone()

bname=book[1]

sql="delete from BOOKS where BCODE=%d"%(bc,)

cur.execute(sql)

print('BOOK NAME- ',bname, 'is deleted')

except:

print("Book doesn't exist")

mydb.commit()

#*****************************************

#TO SEE ISSUED RECORD

def issuerec():

sql="select * from ISSUE"

cur.execute(sql)

d=cur.fetchall()

print("ID NAME B-NAME B-ID DATE STATUS")

for i in d:

print( i[1],' ',i[2],' ',i[3],' ',i[4],' ',i[5],' ',i[6])

if len(d)==0:

print("No Book Issued")


#*****************************************

#TO SEE RETURNED RECORD

def returnrec():

sql="select * from BRETURN"

cur.execute(sql)

d=cur.fetchall()

print("ID NAME B-NAME B-ID DATE")

for i in d:

print( i[1],' ',i[2],' ',i[3],' ',i[4],' ',i[5])

if len(d)==0:

print("No Book returned")

#*****************************************

#TO EXIT FROM LIBRARY

def exit():

print("PLEASE VIST AGAIN (•‿•)")

pass

#*****************************************

#MENU

def menu():

print('\n')

print('\t\t************************************\t\t')

print("\t\t\tLIBRARY MANAGEMENT\t\t\t")

print(" 1. Display books \n 2. Issue a book \n 3. Return a book \n 4. Add a book \n 5. Delete a book \n
6. Issued books \n 7. Returned books \n 8. Exit")

ch=(input(" Enter your task:- "))

if ch=='1':

print("BOOK LIST...")

books()
menu()

elif ch=='2':

print("ISSUING BOOK...")

issue()

menu()

elif ch=='3':

print("RETURNING BOOK...")

Return()

elif ch=='4':

print("ADDING BOOK...")

addb()

menu()

elif ch=='5':

print("DELETING BOOK...")

deleteb()

menu()

elif ch=='6':

print("ISSUED BOOKS RECORD...")

issuerec()

menu()

elif ch=='7':

print("RETURNED BOOKS RECORD...")

returnrec()

menu()

elif ch=='8':

exit()

else:

print("Invalid task")

menu()
OUTPUTS
SQL TABLE STRUCTURES
BIBLIOGRAPHY

1. The Python Tutorial — Python 3.10.7 documentation


2. Text Book for class XII – NCERT
3. Text Book for class XII – Preeti Arora (Sultan Chand Publication)
4. Text Book for class XII – Sumita Arora (Dhanpat Rai Publication)
THANK YOU

You might also like