Library Mangement-2
Library Mangement-2
(SHIFT-I)
LIBRARY MANAGEMENT
UNDER GUIDANCE OF : PREPARED BY :
PRINCIPAL
DECLARATION
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.
__________________
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.
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;
USE LIBRARY;
AMT INT);
#*****************************************
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)
#*****************************************
def books():
cur.execute(a)
d=cur.fetchall()
Books=cur.fetchall()
if len(Books)==0:
else:
for i in d:
#*****************************************
def issue():
try:
if len(Books)==0:
else:
books()
data=(p,i,n,b,d)
bc=cur.fetchone()
if bc and b==bc[0]:
cur.execute(sql)
mydb.commit()
cur.execute(sq,(b,))
mydb.commit()
print('BOOK IS UNAVAILABLE')
else:
except ValueError:
def Return():
try:
for i in cur:
print(i)
cur.execute(sql)
mydb.commit()
cur.execute(sq,(b,))
mydb.commit()
cur.execute(s)
mydb.commit()
break
else:
except ValueError:
def addb():
try:
existbook=cur.fetchone()
if existbook:
newn=existbook[3]+a
cur.execute(sql)
mydb.commit()
else:
data=(c,b,n,a)
cur.execute(sql)
mydb.commit()
menu()
except ValueError:
def deleteb():
try:
books()
book=cur.fetchone()
bname=book[1]
cur.execute(sql)
except:
mydb.commit()
#*****************************************
def issuerec():
cur.execute(sql)
d=cur.fetchall()
for i in d:
if len(d)==0:
def returnrec():
cur.execute(sql)
d=cur.fetchall()
for i in d:
if len(d)==0:
#*****************************************
def exit():
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")
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':
issuerec()
menu()
elif ch=='7':
returnrec()
menu()
elif ch=='8':
exit()
else:
print("Invalid task")
menu()
OUTPUTS
SQL TABLE STRUCTURES
BIBLIOGRAPHY