Computer Science Project
Computer Science Project
def addbook():
code=int(input('Enter book code :'))
name=input('Enter book name :')
author=input('Enter book author name :')
type=input('Enter book type :')
price=int(input('Enter book price :'))
rentprice=int(input('Enter book rented price :'))
cur_obj=con_obj.cursor()
data="insert into
books(Book_code,Book_name,Book_author,Book_type,Bo
ok_price,Book_rentprice) values({},'{}','{}','{}',{},
{})".format(code,name,author,type,price,rentprice)
cur_obj.execute(data)
con_obj.commit()
print('*'*20)
print('Book information addetion is successfull')
option()
def issuebook():
reg=int(input('Enter regestration no :'))
name=input('Enter candidate name :')
code=int(input('Enter book code :'))
date=input('Enter date of purchase :')
qut=int(input('Enter no books taken :'))
cur_obj=con_obj.cursor()
data="insert into
issuedbook(Reg_no,Name,Book_code,Purchase_date,Book
_qut) values({},'{}',{},'{}',
{})".format(reg,name,code,date,qut)
cur_obj.execute(data)
con_obj.commit()
print('*'*20)
print('Book issued by ',name)
option()
def editbook():
nname=input('enter new book name:')
nauthor=input('enter new book author name:')
ntype=input('rnter new book type:')
nprice=int(input('Enter new price :'))
nrentprice=int(input('enter new rent price:'))
code=int(input('Enter book code to be updated :'))
cur_obj=con_obj.cursor()
data="update books set Book_name={} and
Book_author={} and Book_type={} and Book_price={}
and Book_rentprice={} where
Book_code={}".format(nname,nauthor,ntype,nprice,nren
tprice,code)
cur_obj.execute(data)
con_obj.commit()
print('*'*20)
print('Book updation successfull')
option()
def returnbook():
print('*'*20)
print('Book Returnd by ',name)
option()
def deletebook():
code=int(input('Enter book code :'))
cur_obj=con_obj.cursor()
data="delete from books where
Book_code={}".format(code)
cur_obj.execute(data)
record=cur_obj.fetchall()
con_obj.commit()
print('*'*20)
print('Book records has been deleted successfully')
option()
def searchbook():
code=int(input('Enter book code to be surched :'))
cur_obj=con_obj.cursor()
data="select * from books where
Book_code={}".format(code)
cur_obj.execute(data)
record=cur_obj.fetchall()
for row in record:
print(record)
con_obj.commit()
print('*'*20)
print('Surch successfull')
option()
def showbook():
cur_obj=con_obj.cursor()
data="select * from books"
cur_obj.execute(data)
record=cur_obj.fetchall()
print(record)
con_obj.close()
print('*'*20)
print('All details are shownd')
option()
def option():
print(""" LIBRARY MANAGEMENT
OPTIONS
1 ADD BOOKS
2 ISSUE BOOKS
3 EDIT BOOKS
4 RETURN BOOKS
5 DELETE BOOKS
6 SEARCH BOOKS
7 SHOW BOOKS
8 LOG OUT
""")
ch=int(input('Enter your option :'))
print('<<<<---------------------------------------------------------------
------>>>>')
if ch==1:
addbook()
elif ch==2:
issuebook()
elif ch==3:
editbook()
elif ch==4:
returnbook()
elif ch==5:
deletebook()
elif ch==6:
searchbook()
elif ch==7:
showbook()
elif ch==8:
print(" LOGOUT ")
else:
print('Wrong chooice')
option()
def log_in():
print(" welcome to library management system ")
user=input(' Enter username :')
passwd=input(' Enter passwd :')
if user!='acv1942':
print('ckeck you user name')
log_in()
elif passwd!='py1942':
print('Wrong passwd')
lon_in()
else:
option()
log_in()
output: