t
t
DHANPURI
PROJECT TOPIC:
LIBRARY MANAGEMENT SYSTEM
CERTIFICATE
PRINCIPAL
ACKNOWLEDGMENT
HARDWARES
Desktop Computer/Laptop
Mobile Phone
SOFTWARES
Python(latest version)
MySQL
MySQL-Connector-Python
TABLE OF CONTENTS
S.No
. Topic Page No.
1 Certificate 1
2 Acknowledgement 2
Hardwares and
Softwares
3 Required 3
4 Introduction 5
5 Python Source Code 10
6 MySQL Database 45
7 Outputs 48
8 References 56
INTRODUCTION
#FUNCTION TO LOGIN
def login():
#print("-" * 40)
print("\t Library Management System")
#print("-" * 40)
print("\t LOGIN")
un = input("Enter User Name : ")
pw = input("Enter Password : ")
q = "select * from users where username = %s and passw =
%s"
val = (un,pw)
c2 = db1.cursor()
c2.execute(q,val)
res = c2.fetchall()
print("-" * 50)
if len(res) == 0:
print("Invalid User Name or Password ")
print("-" * 50)
return False
else:
print("Access Granted !!!")
print("-" * 50)
return True
cursor1 = db1.cursor()
q = "insert into member values (%s,%s,%s,%s)"
val = (mid,name,phone,email)
cursor1.execute(q,val)
db1.commit()
print("Member Added Successfully")
#FUNCTION TO SHOW MEMBERS
def showMembers():
cursor1 = db1.cursor()
cursor1.execute("Select * from Member")
res = cursor1.fetchall()
print("-" * 50)
print(" MEMBER DETAILS ")
print("-" * 50)
print("Id Name Email Phone ")
for k in res:
print(k[0]," ",k[1]," ",k[2]," ",k[3])
def issueBook():
bid = input("Enter the book id to be issued : ")
q ="select * from issue where bookid='" + bid +"'"
cursor1 = db1.cursor()
cursor1.execute(q)
res = cursor1.fetchall()
if len(res)== 0:
mid = input("Enter the member id : ")
doi = input("Enter the date of issue : ")
q = "insert into issue (mid,bookid,dateofissue)
values(%s,%s,%s)"
data = (mid,bid,doi)
cursor1.execute(q,data)
db1.commit()
print("-" * 40)
print(" Book Issued Successfully")
print("-" * 40)
else:
print("-" * 40)
print(" Sorry ! The Book is not available")
print("-" * 40)
connect()
print("Connected")
print(" WELCOME TO LIBRARY")
if login():
while True:
print("-" * 50)
print("\t CHOOSE AN OPERATION ")
print("-" * 50)
print("Press 1 - Add a New Member")
print("Press 2 - Delete an Existing Member")