0% found this document useful (0 votes)
2 views

Computer Science Project

The document outlines a library management system implemented in Python, utilizing MySQL for database operations. It includes functions for adding, issuing, editing, returning, deleting, searching, and displaying books, as well as a login system for user authentication. The code features a menu-driven interface for user interaction with the library system.

Uploaded by

rajputalpumanish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Computer Science Project

The document outlines a library management system implemented in Python, utilizing MySQL for database operations. It includes functions for adding, issuing, editing, returning, deleting, searching, and displaying books, as well as a login system for user authentication. The code features a menu-driven interface for user interaction with the library system.

Uploaded by

rajputalpumanish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Computer science project

Library management system


Source code:
import mysql.connector as lib
con_obj=lib.connect(host='localhost',user='root',passwd
='3110vish',database='librarymanagement',charset='utf
8')

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():

reg=int(input('Enter regestration no :'))


name=input('Enter candidate name :')
code=int(input('Enter book code :'))
date=input('Enter date of returned book :')
rent=int(input('Enter book rent price :'))
qut=int(input('Enter no books taken :'))
fine=input('Enter book late submition fine :')
cur_obj=con_obj.cursor()
data="insert into
returnbook(Reg_no,Name,Book_code,Return_date,Book_r
entprice,Book_qut,Latesub_fine) values({},'{}',{},'{}',{},
{},{})".format(reg,name,code,date,rent,qut,fine)
cur_obj.execute(data)
con_obj.commit()

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:

You might also like