You are on page 1of 20

Guru harkirshan

public school
Library management
system …

Submitted by:
Jashandeep singh
xii-b
CERTIFICATE

This is to certify that JASHANDEEP SINGH, a


student of class XII – B has successfully
completed the research on the below
mentioned project under the guidance of
Mrs. Mala Maam during the year 2023-2024
in partial fulfilment of computer science
practical examination conducted by CBSE
New Delhi .
ACKNOWLEDGEMENT
I would like to express my special
thanks of gratitude to my teacher Mrs
MALA who gave me the golden
opportunity to do this wonderful
project on the topic library
management system , which also
helped me in doing a lot of Research
and I came to know about so many
new things I am really thankful
tothem. Secondly i would also like to
thank my parents and friends who
helped me a lot in finalizing this
project within the limited time frame
Contents:-
1.Introduction
2.System Requirements
3.Source Code
4.Output in python
5.Output in mysql
6.Bibliography
Intoduction:-

MySQL is one of the most popular database


management systems (DBMSs) on the market
today. It ranked second only to the Oracle DBMS in
this year’s DB-Engines Ranking. As most software
applications need to interact with data in some
form, programming languages like Python provide
tools for storing and accessing these data sources.
Using the techniques discussed in this tutorial,
you’ll be able to efficiently integrate a MySQL
database with a Python application. You’ll develop
a small MySQL database for a movie rating system
and learn how to query it directly from your
Python code.
System requirement of projects:-\

1.Windows operating system


2.Python IDLE
3.Mysql
4.Mysql.connector
Source code(In Python):-

# Checking mysql connectivity:-

import mysql.connector as c
con=c.connect(host='localhost',user='root',passwd='pagalhaitu',
database='library')
if con.is_connected():
print('Successfully connected to the database......')

# Creating a function to add books:-

def addbook():
c=int(input("Enter Book Code:"))
bn=input("Enter Book Name: ")
ba=input("Enter Author's Name: ")
t=int(input("Total Books:"))
data=(c,bn,ba,t,)
sql='insert into book values(%s,%s,%s,%s);'
c=con.cursor()
c.execute(sql,data)
con.commit()
print("\n\n\n\nBook Added Successfully..........\n\n\n\n")
wait = input('\n\n\nPress enter to continue.....\n\n\n\n\n\n')
main()
# Creating a function for issued books:-

def issueb():
co=int(input('Enter Book Code:'))
n=input('Enter Name:')
r=int(input("Enter Regno.:"))
d=input('Enter Date:')
a="insert into issue values(%s,%s,%s,%s);"
data=(co,n,r,d)
cursor=con.cursor()
cursor.execute(a,data)
con.commit()
print('Book issued successfully')
wait=input('Press enter to continue')
bookup(co,-1)
main()

# Creating a function for returned books:-

def returnb():
co=int(input('Enter Book Code:'))
n=input('Enter Name:')
r=int(input("Enter Regno.:"))
d=input('Enter Date:')
a="insert into returned values(%s,%s,%s,%s);"
data=(co,n,r,d)
cursor=con.cursor()
cursor.execute(a,data)
con.commit()
print('Book returned by:',n)
wait=input('Press enter to continue')
bookup(co,1)
main()

# Creating a function for the book quantity:-

def bookup(co,u):
a='select quantity from book where bcode=%s;'
data=(co,)
c=con.cursor()
c.execute(a,data)
myresult=c.fetchone()
t=myresult[0]+u
sql="update book set quantity=%s where bcode=%s;"
d=(t,co)
c.execute(sql,d)
con.commit()
wait = input('\n\n\nPress enter to continue.....\n\n\n\n\n\n')
main()

# Creating a function for the deletion of a book:-

def dbook():
ac=int(input("Enter Book Code: "))
a= "delete from book where bcode=%s;"
data=(ac,)
c=con.cursor()
c.execute(a,data)
con.commit()
print("Book deleted successfully")
wait = input('\n\n\nPress enter to
continue.....\n\n\n\n\n\n\n\n\n\n\n\n')
main()

# Creating a function to display book details:-

def dispbook():
a="select * from book;"
c=con.cursor()
c.execute(a)
myresult=c.fetchall()
for i in myresult:
print("Book code:",i[0])
print("Author:",i[1])
print("Book name:",i[2])
print("Quantity:",i[3])
print('\n\n')
wait = input('\n\n\nPress enter to
continue.....\n\n\n\n\n\n\n\n\n\n\n\n')
main()

# Creating a function to give report on isssued books:-

def report_issued_books():
a="select * from issue;"
c=con.cursor()
c.execute(a)
myresult=c.fetchall()
for i in myresult:
print(myresult)

wait = input('\n\n\nPress enter to


continue.....\n\n\n\n\n\n\n\n\n\n\n\n')
main()

# Creating a function to give report on returned books:-


def report_return_books():
a= 'select* from returned;'
c=con.cursor()
c.execute(a)
myresult=c.fetchall()
for i in myresult:
print(myresult)

wait = input('\n\n\nPress enter to


continue.....\n\n\n\n\n\n\n\n\n\n\n\n')
main()

# Library management system:-

def main():
print("""
1. ADD BOOK
2. ISSUE OF BOOK
3. RETURN OF BOOK
4. DELETE BOOK
5. DISPLAY BOOKS
6. REPORT MENU
7. EXIT PROGRAM""")
choice=input("Enter Task No:......")
print('\n\n\n\n\n\n\n')
if(choice=='1'):
addbook()
elif(choice=='2'):
issueb()
elif(choice=='3'):
returnb()
elif(choice=='4'):
dbook()
elif(choice=='5'):
dispbook()
elif(choice=='6'):
print('''
REPORT MENU:
1. ISSUED BOOKS
2. RETURNED BOOKS
3. GO BACK TO MAIN MENU \n\n\n''')
choice=input("Enter Task No:......")
print('\n\n\n\n\n\n\n')
if choice=='1':
report_issued_books()
elif choice=='2':
report_return_books()
elif choice=='3':
main()
else:
print("PIease try again........\n\n\n\n\n\n\n\n\n")
main()
elif(choice=='7'):
print('Thank you and have a great day ahead
ahead...............\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n')
else:
print("Please try again........\n\n\n\n\n\n\n\n\n\n\n\n")
main()

main()
Output in python:-
Output in mysql:-

You might also like