Vansh IP Project
Vansh IP Project
PRACTICES
PROJECT
1
GROUP MEMBERS
✓ VANSH KUMAR
✓ AMAN PRATAP SINGH
ROLL NO. – 26
2
This is to certify that the project/Dissertation
Entitled
LIBRARY MANAGEMENT is a bonafide work done by Vansh Kumar
of Class XII Session 2020-2021 in partial fulfillment of CBSE’s BOARDS
Examination 2020-2021 and has been carried out under my direct
supervision and guidance.
This report or a similar report on the topic has not been submitted for
any other examination and does not form a part of any other course
undergone by the candidate.
…………………….. …………………………
…………………………..
Signature of Examiner
DATE : …………………………..
3
INDEX
➢ Acknowledgement
➢ Mysql Database Screenshot
➢ Python File
• Main File
• libsubmenu
• libbooksrecord
• updatelib
• vanshlib
➢ Sample Output Screenshot
➢ Bibliography
➢ Conclusion
4
ACKNOWLEDGEMENT
I undertook this project work, as the part of my XII-Informatics
practices course. I had tried to apply my best of knowledge and
experience gained during the study and class work experience.
VANSH KUMAR
CLASS XII
5
Mysql
database
6
PYTHON FILE
Main File
import libsubmenu
print("======================================================")
print(" LIBRARY MANAGEMENT ")
print("======================================================")
while True:
try:
print('Press 1 for login')
print('press 2 for exit')
print("======================================================")
ch=input('enter your choice: ')
if ch=='1':
def pswd():
ps=input("Enter Password : ")
if ps=="aman":
libsubmenu.main()
else:
print("Wrong Password *__*")
pswd()
def userid():
7
us=input("Enter User ID : ")
if us=="aman":
pswd()
else:
print("Ooops Wrong User ID")
userid()
userid()
elif ch=='2':
break
else:
print('Wrong input')
print("======================================================")
except Exception as e:
print(e)
8
libsubmenu
#importing pandas
import pandas as pd
#for importing vanshlib file
import Vanshlib
#for importing libbooksrecord
import libbooksrecord
#for defining main function
def main():
print("======================================================")
#sub menu
while True:
#for handling error
try:
print("Press 1 to get books record")
print("Press 2 to issues books")
print("Press 3 to submit books")
print("Press 4 to previous menu")
print("======================================================")
ch=input("Enter your choice")
print("======================================================")
if ch=="1":
#books record
libbooksrecord.main()
elif ch=="2":
#issues books
Vanshlib.main()
9
elif ch=="3":
#submit books
Vanshlib.main()
elif ch=="4":
#previous menu
break
else:
#for wrong input
print("Wrong input")
print("======================================================")
except Exception as e:
print(e)
10
libbooksrecord
print("======================================================")
ch=input("Enter the choice: ")
print("======================================================")
# To add books record
if ch=='1':
#calling addb function
11
addb()
a=input("Press enter key to continue")
print("======================================================")
print(" Book record is deleted
")
print("======================================================")
#for saving the records
mycon.commit()
a=input("Press enter key to continue")
# To view books record
elif ch=='3':
query=("select *from books_record")
mycursor.execute(query)
ss=mycursor.fetchall()
df=pd.DataFrame(ss,columns=['Name of
book','Edition','Publisher','Book_Code','Author','Price','Number of books'])
#for displaying record
print(df)
a=input("Press enter key to continue")
elif ch=='4':
#calling function to update books record
updatelib.main()
elif ch=='5':
#To go in previous menu
break
else:
#if wrong input
12
print("======================================================")
print(" Wrong Input Try Again! ")
print("======================================================")
except Exception as e:
print(e)
#defining function for adding book record
def addb():
name=input('Enter name of books :')
Book_Code=input('enter Book_Code of book: ')
author=input("enter author's name :")
publisher=input("enter book publisher's name :")
edition=input('enter book edition year in (YYYY-MM-DD) : ')
price=int(input('enter book price :'))
book_number=int(input('enter number of books : '))
#creating query
query="select Book_Code from books_record where Book_Code='{}'"
mycursor.execute(query.format(Book_Code,))
bnb=mycursor.fetchone()
if bnb[0]==Book_Code:
#ceating query to update
query="update books_record set book_number=book_number+{}
where Book_Code='{}'"
mycursor.execute(query.format(book_number,Book_Code))
print("======================================================")
print(" Book number is updated")
print("======================================================")
#for saving
mycon.commit()
else:
query="insert into books_record values('{}','{}','{}','{}','{}',{},{})"
13
mycursor.execute(query.format(name,edition,publisher,Book_Code,autho
r,price,book_number))
print("======================================================")
print(" Book record is added ")
print("======================================================")
#for saving the records
mycon.commit()
14
updatelib
#updation
#importing pandas
import pandas as pd
#importing sql
import mysql.connector as sqltor
#establishing connection
mycon=sqltor.connect(host='localhost',user='root',passwd='chunar@123',
database='vanshlib')
#creating cursor
mycursor=mycon.cursor()
#for defining main function
def main():
while True:
#For handling error
try:
# for updation
print('Press 1 to update name of book : ')
print('Press 2 to update author name : ')
print('Press 3 to update publisher name : ')
print('Press 4 to update edition year : ')
print('Press 5 to update price : ')
print('Press 6 to update number of books : ')
print('press 7 to previous menu')
print("======================================================")
#to enter option
option=input("Enter the option")
print("======================================================")
15
if option=='1':
#book name
Book_Code=input("Enter Book_Code of the book you want to
update")
newname=input("Enter new name : ")
query="update books_record set name_of_books='{}' where
Book_Code='{}' "
mycursor.execute(query.format(newname,Book_Code))
print("======================================================")
print("======================================================")
print(" Book name is updated ")
print("======================================================")
print("======================================================")
#for saving
mycon.commit()
a=input("Press enter key to continue")
elif option=='2':
#author name
Book_Code=input("Enter Book_Code of the book you want to
update")
newauthorname=input("Enter new author name : ")
query="update books_record set author='{}' where
Book_Code='{}'"
mycursor.execute(query.format(newauthorname,Book_Code))
print("======================================================")
print("======================================================")
print(" Book author name is updated
")
16
print("======================================================")
print("======================================================")
#for saving
mycon.commit()
a=input("Press enter key to continue")
elif option=='3':
#publisher name
Book_Code=input("Enter Book_Code of the book you want to
update")
newpubname=input("Enter new publisher name : ")
query="update books_record set published_by ='{}'where
Book_Code='{}'"
mycursor.execute(query.format(newpubname,Book_Code))
print("======================================================")
print("======================================================")
print(" Book publisher name is updated
")
print("======================================================")
print("======================================================")
#for saving
mycon.commit()
a=input("Press enter key to continue")
elif option=='4':
#edition year
Book_Code=input("Enter Book Code of the book you want to
update")
newedition=input("Enter new edition : ")
query="update books_record set edition='{}' where
Book_Code='{}'"
17
mycursor.execute(query.format(newedition,Book_Code))
print("======================================================="
)
print("======================================================")
print(" Book edition year is updated
")
print("======================================================")
print("======================================================")
#for saving
mycon.commit()
a=input("Press enter key to continue")
elif option=='5':
#price
Book_Code=input("Enter Book_Code of the book you want to
update")
newprice=int(input("Enter new price : "))
query="update books_record set price ={} where Book_Code='{}'"
mycursor.execute(query.format(newprice,Book_Code))
print("======================================================")
print("======================================================")
print(" Book price is updated
")
print("======================================================")
print("======================================================")
#for saving
mycon.commit()
a=input("Press enter key to continue")
18
elif option=='6':
#To update number of books
Book_Code=input("Enter Book_Code of the book you want to
update")
book_number=int(input("Enter new number of books : "))
query="update books_record set book_number ={} where
Book_Code='{}'"
mycursor.execute(query.format(book_number,Book_Code))
print("======================================================")
print("======================================================")
print(" number of books is updated ")
print("======================================================")
print("======================================================")
#for saving
mycon.commit()
a=input("Press enter key to continue")
elif option=='7':
#Previous menu
break
else:
#for wrong input
print("Wrong Input Try Again!")
print("======================================================")
a=input("Press enter key to continue")
except Exception as e:
print(e)
19
vanshlib
import pandas as pd
import mysql.connector as a
con=a.connect(host="localhost",user="root",passwd="chunar@123",datab
ase="vanshlib")
#defining function to issue the book
def issueb():
n=input("Enter the Name of Student :")
r=input("Enter the Reg No of Student :")
query=("select *from books_record")
c=con.cursor()
c.execute(query)
ss=c.fetchall()
df=pd.DataFrame(ss,columns=['Name of
book','Edition','Publisher','Book_Code','Author','Price','Number of books'])
#for displaying record
print(df)
co=input("Enter the Book Code :")
d=input("Enter Date :")
a="select book_number from books_record where Book_Code='{}'"
c.execute(a.format(co,))
myresult=c.fetchone()
if myresult[0]>0:
a="insert into ISSUES values('{}','{}','{}','{}')"
data=(n,r,co,d)
c.execute(a.format(n,r,co,d))
con.commit()
print("======================================================")
print("Book issued to :",n)
20
bookup(co,-1)
else:
print("======================================================")
print("Book is not available")
print("======================================================")
print("Book Submited :",n)
a="delete from ISSUES where Stud_Name='{}'"
c.execute(a.format(n,))
con.commit()
#for book no. update
def bookup(cd,bn):
a="select book_number from books_record where Book_Code='{}'"
c=con.cursor()
c.execute(a.format(cd,))
myresult=c.fetchone()
t=myresult[0] + bn
sql="update books_record set book_number={} where Book_Code='{}'"
c.execute(sql.format(t,cd))
con.commit()
#defining function to display issues table
def dispissues():
21
a="select * from ISSUES"
c=con.cursor()
c.execute(a)
myresult=c.fetchall()
for i in myresult:
print("Student Name :",i[0])
print("Reg No :",i[1])
print("Book Code :",i[2])
print("Date of Issue :",i[3])
print("======================================================")
#defining function to display submit table
def dispsubmit():
a="select * from SUBMIT"
c=con.cursor()
c.execute(a)
myresult=c.fetchall()
for i in myresult:
print("Student Name :",i[0])
print("Reg No :",i[1])
print("Book Code :",i[2])
print("Date of Submit :",i[3])
print("======================================================")
#defining function of main
def main():
while True:
try:
print('''|------------------------------------------------------------------------
--------------------------|
1. ISSUE BOOKS
|--------------------------------------------------------------------------------------------------
|
2. SUBMIT BOOK
22
|--------------------------------------------------------------------------------------------------
|
3. DISPLAY ISSUES
|--------------------------------------------------------------------------------------------------
|
4. DISPLAY SUBMISSION
|--------------------------------------------------------------------------------------------------
|
5. PREVIOUS MENU
|--------------------------------------------------------------------------------------------------
|''')
Choice=input("Enter Task No :")
print("|-------------------------------------------------------------------------
-------------------------|")
if Choice=='1':
print("|-------------------------------------------------------------------
-------------------------------|")
issueb()
print("|-------------------------------------------------------------------
-------------------------------|")
a=input("Press enter key to continue")
elif Choice=='2':
print("|-------------------------------------------------------------------
-------------------------------|")
submitb()
print("|-------------------------------------------------------------------
-------------------------------|")
a=input("Press enter key to continue")
elif Choice=='3':
print("|-------------------------------------------------------------------
-------------------------------|")
dispissues()
print("|-------------------------------------------------------------------
-------------------------------|")
a=input("Press enter key to continue")
23
elif Choice=='4':
print("|-------------------------------------------------------------------
-------------------------------|")
dispsubmit()
print("|-------------------------------------------------------------------
-------------------------------|")
a=input("Press enter key to continue")
elif Choice=="5":
break
else:
print("|-------------------------------------------------------------------
-------------------------------|")
print("=======================================================
=========")
print("Wrong Choice.........")
print("=======================================================
=========")
print("|-------------------------------------------------------------------
-------------------------------|")
except Exception as e:
print(e)
24
SAMPLE
OUTPUT
25
BIBLIOGRAPHY
(1) http://www.mysql.org/
(2) http://www.python.org/
26
CONCLUSION
Here I have come to the end of the IP Project on Python & Mysql.
Its been a great opportunity for me to be on this amazing project.
I learned a lot about coding in Python & creating and manipulating
databases in Mysql.
Thank You
27