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

Vinod

This document contains a source code for a library management system project in Python. The code includes functions for registering new members, checking out and returning books, adding new books to the library collection, and retrieving records from the database tables to view member, book, book issue, and book return information. The full source code and documentation is provided for review by the teacher.
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)
66 views27 pages

Vinod

This document contains a source code for a library management system project in Python. The code includes functions for registering new members, checking out and returning books, adding new books to the library collection, and retrieving records from the database tables to view member, book, book issue, and book return information. The full source code and documentation is provided for review by the teacher.
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

RAJEEV GANDHI

NAVODAYA VIDYALAYA
KOTABAGH , [NTL]
(SESSION-2023-2024 )

PROJECT WORK OF
COMPUTER SCIENCE
TOPIC-LIBRARY MANAGEMENT SYSTEM

GUIDED TO: GUIDED BY


ANKIT BUHLAKOTI MR. R.C. SANWAL
CLASS: 12TH [PGT COMPUTER
i.d-822 SCIENCE]

 Certificate
This is to that Ankit Budhlakoti of
class/section 12B, Rajeev Gandhi
Navodaya viyalaya Syat Kotabagh
Nainital, has successfully completed the
project entitled “library management
system” in computer science for the
AISSCE as prescribed by CBSE in the
academic year 2023-24. The project is
the result of his efforts & eneavours.
Date:
(Signature of the teacher)…………………
External Examinar Sign……………………
ACKNOWLEGEMEN
T
It is my privilege to express my most
sincere regards to all who directly or
indirectly helped me to complete my
project work.
I herby, acknowledge my heartiest
gratitude to my computer science
teacher Mr. Ramesh Chandra Sanwal
for his valuable inputs, encouragement,
whole-hearted cooperation that led me
all the way to accomplish this project
based on Library Management system.
I take this opportunity to thank
all my teachers, parents & guidance that
have been very helpful in various
phases of the completion of the project.
 Source
code
 LIBRARY MANAGEMENT SYSTEM
_________________________________________

#MAIN---
print("------------------------------------------WELCOME TO THE
LIBRARY----------------------------------------------------------------- ")

print()

Z= None

U=None

menu()

-----------------------------------------------------------------------------------------------------

#connectoins---
import mysql.connector as sqltor

mycon= sqltor.connect(host='localhost',user='root',passwd='111')

cursor=mycon.cursor()

cursor.execute("create database if not exists library")

cursor.execute("use library")

cursor.execute("create table if not exists books (BOOK_ID INT(10) PRIMARY KEY,


BOOK_NAME VARCHAR(25),AUTHOR_NAME VARCHAR(25),BOOK_COST INT(4),QUANTITY
INT(4))")

cursor.execute("create table if not exists MEMBERS( MEMBER_ID INT(5) PRIMARY KEY,


MEMBER_NAME VARCHAR(25) ,MEMBER_AGE INT(3), MEMBER_ADDRESS VARCHAR(25))")

cursor.execute("create table if not exists book_issue ( MEMBER_ID INT(4),BOOK_ID INT(4),


BOOK_NAME VARCHAR(25),ISSUE_DATE DATE, ISSUED_BOOK_QUANTITY INT (3))")
cursor.execute("create table if not exists book_return ( MEMBER_ID INT(4),BOOK_ID INT(4),
BOOK_NAME VARCHAR(25),RETURN_DATE DATE, RETURNED_BOOK_QUANTITY INT (3))")

mycon.commit()

from datetime import date

#functions---
def menu():

print("SELECT ANY OPTION:")

print("--> MENU:")

print(" 1.NEW MEMBER ")

print(" 2.ALREADY A MEMBER ")

print(" 3.STAFF PAGE" )

print(" 4.EXIT")

X=int(input(" ENTER CHOICE:"))

if X==1:

register()

elif X==2:

check()

elif X==3:

passwd()

elif X==4:

print()

print("THANKS FOR VISITING__________")

while True:

break

else:

print("INVALID CHOICE--")

while True:
continue

def register():

print("PLEASE FILL THE FOLLOWING DETAILS_______")

name= input(" Enter your NAME :")

age =int(input(" Enter your AGE :"))

address=input(" Enter your ADDRESS :")

A=int(input(" Please enter a numerical ID as your new MEMBER_ID:"))

check1(A)

cursor.execute("insert into MEMBERS(MEMBER_ID, MEMBER_NAME ,MEMBER_AGE ,


MEMBER_ADDRESS)VALUES({},'{}',{},'{}')".format(U,name, age ,address))

mycon .commit()

print()

print("REGISTRATION SUCESSFULL ")

print("WELCOME TO THE LIBRARY--")

options()

def options():

print()

print("---SELECT ANY OPTION TO PROCEED....")

print(" 1. CHECK LIST OF BOOKS ")

print(" 2. ISSUE BOOK ")

print(" 3. RETURN BOOK ")

print(" 4. GO BACK")

print("")

choice=int(input("Enter your choice:"))


if choice== 1:

print(book_check())

options()

elif choice==2:

print()

issue()

options()

elif choice==3:

book_return()

options()

elif choice==4:

menu()

else:

print("INVALID CHOICE--")

options()

def staff():

a='y'

while a=='y':

print("--SELECT ANY OPTION TO PROCEED....")

print(" 1. CHECK BOOKS LIST ")

print(" 2. NEW BOOK ENTRY ")

print(" 3. DELETE BOOK RECORD")

print(" 4. CHECK MEMBERS LIST")

print(" 5. DELETE MEMBER'S RECORD")

print(" 6. CHECK ISSUE BOOKS RECORD ")


print(" 7. CHECK RETURNED BOOKS RECORD ")

print(" 8. DELETE ISSUE RECORD ")

print(" 9. DELETE RETURN RECORD")

print(" 10. GO BACK")

choice1=int(input("Enter your choice:"))

if choice1==1:

print()

book_check()

continue

elif choice1==2:

print()

addbook()

continue

elif choice1==3:

delete_record()

continue

elif choice1==4:

print(memb_list())

continue

elif choice1==5:

del_membrecord()

continue

elif choice1==6:

issue_record()

continue

elif choice1==7:

return_record()
continue

elif choice1==8:

del_issue_record()

continue

elif choice1==9:

del_return_record()

continue

elif choice1==10:

menu()

continue

else:

print("INVALID CHOICE--")

staff()

print()

a='x'

def passwd():

for i in range(0,3):

paswd=int(input("ENTER CORRECT 3-DIGIT SECURITY PASSWORD IN 3 ATTEMPTS:"))

if paswd==123:

print()

print("WELCOME TO STAFF FACE---")

staff()

break

else:

print("WRONG PASSWORD!!")
continue

print("_______________________________________________________")

menu()

def issue():

print("PLEASE FILL THE DETAILS____")

print()

A=check2()

h=int(input(" ENTER THE BOOK_ID:"))

cursor.execute('select QUANTITY from books where BOOK_ID ={}'.format(h))

d=cursor.fetchall()

k2=d[0]

x=k2[0]

cursor.execute("select BOOK_NAME from books where BOOK_ID ={}".format(h))

t=cursor.fetchall()

k1=t[0]

v=k1[0]

i= date.today()

print()

print("BOOK_NAME :",v)

print("QUANTITY AVAILABLE :",x)

m=int(input("ENTER THE NUMBER OF BOOK YOU WANT TO ISSUE:"))

c=x-m

if x<m:

print()

print(m,'NUMBER OF BOOKS ARE NOT AVAILABLE!!!!')

else:
cursor.execute("insert into book_issue( MEMBER_ID, BOOK_ID, BOOK_NAME , ISSUE_DATE
,ISSUED_BOOK_QUANTITY )values({},{},'{}','{}',{})".format( A,h ,v,i,m))

print('BOOK ISSUED SUCESSFULLY !!_____')

cursor.execute("update books set QUANTITY={} where BOOK_ID={}".format(c,h))

mycon.commit()

def book_return():

print("PLEASE FILL THE DETAILS____")

print()

A=check2()

h=int(input(" ENTER THE BOOK_ID:"))

cursor.execute("select BOOK_NAME from books where BOOK_ID ={}".format(h))

t=cursor.fetchall()

k1=t[0]

v=k1[0]

print("BOOK NAME :",v)

i= date.today()

cursor.execute('select QUANTITY from books where BOOK_ID ={}'.format(h))

d=cursor.fetchall()

k2=d[0]

x=k2[0]

f=int(input("ENTER THE NUMBER OF BOOKS YOU WANT TO SUBMIT :"))

b=input("PRESS 'YES' TO SUBMIT OTHERWISE PRESS 'NO':")

c=x+f

if b=="yes" or b=="Yes" or b=='YES':

cursor.execute("insert into book_return(MEMBER_ID ,BOOK_ID ,


BOOK_NAME ,RETURN_DATE, RETURNED_BOOK_QUANTITY )values({},{},'{}','{}',
{})".format(A,h,v,i,f))
mycon.commit()

print("BOOK RETURNED SUCESSFULLY__________")

cursor.execute("update books set QUANTITY={} where BOOK_ID={}".format(c,h))

mycon.commit()

else:

options()

def addbook():

print("WELCOME TO BOOKS ENTRY SEACTION_______")

a=int(input("Enter BOOK_ID:"))

b=input("Enter BOOK_NAME:")

c=input("Enter AUTHOR_NAME:")

d=int(input("Enter BOOK_COST:"))

e=int(input("Enter BOOK QUANTITY:"))

cursor.execute("INSERT INTO BOOKS(BOOK_ID ,


BOOK_NAME ,AUTHOR_NAME ,BOOK_COST ,QUANTITY) VALUES({},'{}','{}',{},
{})".format(a,b,c,d,e))

mycon.commit()

print("*BOOK REGISTERED SUCESSFULLY* ")

def memb_list():

cursor.execute("SELECT * FROM MEMBERS")

data=cursor.fetchall()

mycon.commit()

d=data

print("LIST OF REGISTERED MEMBERS :")

print()
print(' __ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
__ ')

print('| MEMBER_ID MEMBER_NAME MEMBER_AGE MEMBER_ADDRESS |')

print('|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_|')

for i in d :

print('{:<3}'.format ('|'), '{:<10}'.format (i[0]),'{:<30}'.format


(i[1]),'{:<30}'.format(i[2]),'{:<12}'.format (i[3]),'|')

print('|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_|')

print()

def issue_record():

cursor.execute("SELECT * FROM book_issue ")

data=cursor.fetchall()

mycon.commit()

d=data

print("LIST OF THE BOOKS ISSUED :")

print('______________________________________________________________________
___________________________________ ')

print('| MEMBER_ID BOOK_ID BOOK_NAME ISSUE_DATE QUANTITY_ISSUED


|')

print('|
___________________________________________________________________________
_____________________________|')

for i in d :

print('{:<3}'.format ('|'), '{:<14}'.format (i[0]),'{:<13}'.format


(i[1]),'{:<30}'.format(i[2]),i[3],'{:>15}'.format (i[4]),'{:>15}'.format ('|'))

print('|
___________________________________________________________________________
_____________________________|')
def return_record():

cursor.execute("SELECT * FROM book_return")

data=cursor.fetchall()

mycon.commit()

d=data

print("LIST OF THE BOOKS RETURNED :")

print('______________________________________________________________________
___________________________________ ')

print('| MEMBER_ID BOOK_ID BOOK_NAME RETURN_DATE


QUANTITY_RETURNED |')

print('|
___________________________________________________________________________
_____________________________|')

for i in d :

print('{:<3}'.format ('|'), '{:<14}'.format (i[0]),'{:<13}'.format


(i[1]),'{:<30}'.format(i[2]),i[3],'{:>15}'.format (i[4]),'{:>15}'.format ('|'))

print('|
___________________________________________________________________________
_____________________________|')

def book_check():

cursor.execute("SELECT*FROM books ")

data=cursor.fetchall()

mycon.commit()

d=data

print("LIST OF AVAILABLE BOOKS :")


print('______________________________________________________________________
________________________')

print('| BOOK_ID BOOK_NAME AUTHOR_NAME BOOK_COST QUANTITY |')

print('|
___________________________________________________________________________
__________________|')

for i in d :

print('|', '{:<10}'.format (i[0]),'{:<30}'.format


(i[1]),'{:<30}'.format(i[2]),'{:<10}'.format (i[3]),'{:<7}'.format (i[4]),'|')

print('|
___________________________________________________________________________
__________________|')

def delete_record():

v=int(input("Enter Book Id whose record you want to delete:"))

cursor.execute("delete from books where BOOK_ID={}".format(v))

mycon.commit()

print("RECORD DELETED SUCESSFULLY------")

def del_membrecord():

v=int(input("ENTER THE MEMBER'S_ID WHOSE RECORD YOU WANT TO DELETE :"))

cursor.execute("delete from members where MEMBER_ID={}".format(v))

mycon.commit()

print("RECORD DELETED SUCESSFULLY-------")

def del_return_record():

print("RETURN RECORD:")

return_record()
v=int(input("ENTER THE MEMBER'S_ID WHOSE RECORD YOU WANT TO DELETE :"))

cursor.execute("delete from book_return where MEMBER_ID={}".format(v))

mycon.commit()

print("RECORD DELETED SUCESSFULLY-------")

def del_issue_record():

print("ISSUE RECORD:")

issue_record()

v=int(input("ENTER THE MEMBER'S_ID WHOSE RECORD YOU WANT TO DELETE :"))

cursor.execute("delete from book_issue where MEMBER_ID={}".format(v))

mycon.commit()

print("RECORD DELETED SUCESSFULLY-------")

def check():

s=cursor.execute("SELECT MEMBER_ID FROM MEMBERS")

h=cursor.fetchall()

d=[]

for i in h:

for j in i:

d.append(j)

global Z

Z=int(input("PLEASE ENTER YOUR MEMBER ID:"))

if Z in d :

print("ID MATCHED")

print("ENTERING_______")
options()

else:

print()

print("*YOU ARE NOT A MEMBER OF OUR LIBRARY !! ")

print("**PLEASE BE THE MEMBER OF THE LIBRARY.......")

while True:

break

def check1(x):

s=cursor.execute("SELECT MEMBER_ID FROM MEMBERS")

h=list(cursor.fetchall())

global U

U=x

if x in h:

print("PLEASE ENTER ANOTHER ID ")

register()

else:

return

def check2():

n=int(input(" ENTER YOUR MEMBER ID:"))

if n==Z :

return n

elif n==U :

return n

else:

print("INVALID ID!!!, ENTER YOUR OWN ID.....")

options()
OUTPUTS
 My sql tables
 Bibliography
1. Computer science with PYTHON
by Sumita Arora
2. NCERT website resources
3. www,w3school.com
4. www.python.prg
5. www.google.com

You might also like