#LOGIN MODULE
import
mysql.connector
as ms
db=ms.connect(host="localhost",user="root",password="suni13",database="library")
cn=db.cursor()
cn.execute("select * from login;")
#variable rec is list having all rows and column of list
t=0
un=True
up=False
tuname= " "
pword = " "
def login(uname):
global un
global up
tuname=uname
cn.execute("select * from login")
rec=cn.fetchall()
for i in
range (0,len
(rec
)): while un == True:
if tuname in rec[i][0]:
print("Username found, enter correct password")
up=True
un = False
break
else:
print("Username not found")
print("Please try Again")
tuname = input("Enter username")
if up== True:
break
if up==True and un == False:
pword = input("Enter password")
for i in
range (0,len
(rec
)): while up== True:
if pword in rec[i][1]:
print("User Found")
#CHOICE MODULE
def choice(uname):
ch="" #making variable public for whole function
if uname=='Admin':
print("1 for Adding extra user")
print("2 for removing user")
print("3 for checking all book") #print all the books in main list
print("4 for checking books borrowed")#print all the books in borrowed list along with name
print("5 for list of users")
print("6 for printing all available books")
print("7 for adding extra book")
print("8 for removing extra book")
print("9 for updating passowrd for this current user")
print("M for returning to main menu")
print("O for logging out but not exiting the program")
print("X for closing the program")
ch=input("Please enter choice: ")
else:
print("A for borrowing book")
print("B for returing back book")
print("9 for updating passowrd for this current user")
print("M for returning to main menu")
print("O for logging out and exit")
ch=input("Please enter choice: ")
ch.upper()
return ch
#MANAGER MODULE
import
mysql.connector
as ms
from datetime import
date db=ms.connect(host="localhost",user="root",password="suni13", database="library")
cn=db.cursor() #login table
mn=db.cursor() #library table
def manager(ch,uname):
tuname = uname
if uname=="Admin" and ch=='1': #proper
newname=input("Enter new user name to add")
newpassword=input("Enter password for new username")
cn.execute("insert into login values('0','0')".format(newname,newpassword))
db.commit()
print("Task completed")
print()
elif uname=="Admin" and ch=='2': #proper
a = "Admin"
cn.execute("select * from login where username!='0' ".format(a))
rec=cn.fetchall()
print("Username Passwords")
for i in rec:
print(i)
deluser=input("Enter username to remove")
cn.execute("delete from login where username='(".format(deluser))
db.commit()
print("Task completed")
print()
elif uname=="Admin" and ch=="3": #done
print(Book_Name,",", Book_Type ,",", Borrower ,",",Date_Borrowed)
mn.execute("select * from library;")
rec=mn.fetchall()
try:
tt
.print(list(rec
),header,style
=tt
.styles
.rounded
,padding
=(0,1),) except Exception as e:
print("No Book Available")
#MAINFRAME MODULE
login(tuname)
choice()
manager()
print("********** *LIBRARY MANAGEMENT PROGRAM****************")
uname=input("Enter username")
uname-uname.login(uname)
ch-choice.choice(uname)
print("Entered choice is",ch)
while True:
if ch== 'M' or ch== 'm':
ch-choice.choice(uname)
print("Entered choice is",ch)
manager.manager(ch,uname)
continue
elif ch== '0':
print("Logging out")
print("Successfully logged out")
print("Please login again to continue")
uname = input("Enter username")
uname=login.login(uname)
print("Logged in as",uname)
ch-choice.choice(uname)
print("Entered choice is",ch)
continue
else:
manager.manager(ch,uname)
ch-choice.choice(uname)
print("Entered choice is",ch)
continue