0% found this document useful (0 votes)
13 views28 pages

Computer Science Project - 12

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

Computer Science Project - 12

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

ASAN MEMORIAL

SENIOR SECONDARY SCHOOL


NO.1, Anderson Road, Cochin House, Chennai - 600006

COMPUTER SCIENCE
PROJECT 2022-2023

TITLE OF THE PROJECT

LIBRARY MANAGEMENT SYSTEM

NAME :

CLASS : XII SEC :

REG.NO.:

SUBJECT CODE : 083

SUBJECT : PYTHON
ACKNOWLEDGEMENT
In the accomplishment of this project
successfully So many people have bestowed
upon me their blessings and the heart
pledged support, this time I am utilizing to
thank all people who have been concerned
with the project.

Primarily I would like to thank my


principal MRS.JYOTHI MENON and my
computer science teacher MRS.JULIET
HARRIS whose valuable guidance has been
the ones that helped me patch this project
and make it a full-proof success. Her
suggestions and instructions have served as
the major contributor to the completion of
the project.
CONTENTS

ACHNOWLEDGEMENT
INTRODUCTION
MODULES AND FUNCTIONS
USED
HARDWARE & SOFTWARE
REQUIREMENTS
SOURCE CODE
OUTPUT
BIBLIOGRAPHY
INTRODUCTION
LIBRARY MANAGEMENT:
A library management system is
software that is designed to manage all the
functions of a library. It helps librarian to
maintain the database of new books and the
books that are borrowed by members along
with their due dates.
This system completely automates all your
library's activities. The best way to maintain,
organize, and handle countless books
systematically is to implement a library
management system software.
You can find books in an instant, Issue/reissue
books quickly, and manage all the data efficiently
and orderly using this system. The purpose of a
library management system is to provide instant
and accurate data regarding any type of book,
thereby saving a lot of time and effort.
MODULE AND FUNCTIONS
USED
Tabulate Function
Visualizing the data in tabular form is
easier than visualizing it in a paragraph
or comma-separated form. Nicely
formatted tables not only provide you
with a better way of looking at tables it
can also help in understanding each data
point clearly with its heading and value
.
Tabulate is an open-source python
package/module which is used to print
tabular data in nicely formatted tables.
It is easy to use and contains a variety of
formatting functions.
It has the following functionalities:
One function call for all types
of formatting
Can be downloaded in multiple
output formats
Provides a better presentation
with text and data.

In this article, we will see what are the


different types of table formatting we can
perform using Tabulate.
HARDWARE AND SOFTWARE
REQUIREMENTS

HARDWARE REUIREMENTS :-

INTEL CORE i5 PROCESSOR OR EQUIVALENT


4GB RAM ( 8B PREFERRED)
15GB AVAILABLE HARD DISK SPACE
INTERNET CONNECTION

SOFTWARE REQUIREMENTS:-

WINDOWS 7,10 OR 11
MAC OS X 10.11 OR HIGHER , 64 BIT
LINUX: RHEL 6/7, 64-BIT (ALMOST ALL LIBRARY
WORK)
SOURCE CODE

from tabulate import tabulate

#CREATING DATABASE

import mysql.connector
mydb=mysql.connector.connect(host="localhost",
user="root",passwd="1234") mycursor=mydb.cursor()
mycursor.execute("create database if not exists library")
mycursor.execute("use library")
#CREATING REQUIRED TABLES

mycursor.execute("create table if not exists library_master(cardno char(10) primary


key,name_of_person varchar(30),phone_no char(10),address varchar(30),dob
varchar(10))") mycursor.execute("create table if not exists books(book_name
varchar(30),book_no char(5) primary key,genre varchar(10),authors_name
varchar(15),language varchar(15))") mycursor.execute("create table if not exists
library_transaction(cardno char(10),foreign key(cardno) references
library_master(cardno),book_name varchar(20),date_of_lend date,date_of_return
date)")

#PRINT MENU

while True:
print("")
print("-"*100)
print("MAIN MENU".center(90))
print("-"*100) print("1 Create a new
account") print("2 See the account
info") print("3 Update card holder
info") print("4 Delete the account")
print("5 Add new book") print("6 See
books") print("7 Update book details")
print("8 Delete book") print("9 lend a
book") print("10 return the book")
print("11 display lending history")

print("12 EXIT")
print(" ")
ch=int(input("enter your choice:- "))
print(" ")
#TO CREATE A LIBRARY ACCOUNT

if ch==1:
try: cardno=str(input("enter card no: ")) name_of_person=str(input("Enter
name (limit 30 characters): ")) phone_no=str(input("Enter phone no: "))
address=str(input("Enter the address (max 30 words): "))
dob=str(input("Enter the date of birth(yyyy-mm-dd): "))
mycursor.execute("insert into library_master
values('"+cardno+"','"+name_of_person+"','"+phone_no+"',

'"+address+"','"+do b+"')")
mydb.commit() print("ACCOUNT IS SUCCESSFULLY
CREATED!!!")

except Exception as e: print("Something


went wrong ",e)

#TO SEE DETAILS OF CARD HOLDER

if ch==2:
try: cardno=str(input("Enter card no:- ")) mycursor.execute("select
* from library_master where cardno='"+cardno+"'")
print(tabulate(mycursor,headers=['Card No.','Name','Phone

No','Address','DOB'],tablefmt='psql'))
except Exception as e: print("Something
went wrong ",e)
#TO UPDATE CARD HOLDER INFORMATION

if ch==3:
try: print("") print("press 1 to update name:")
print("press 2 to update phone no:") print("press 3
to update address:") print("press 4 to update date
of birth:") print("press 5 to update ALL the
details:") ch1=int(input("Enter your choice:- "))

except Exception as e: print("Something


went wrong ",e)

#TO UPDATE NAME

if ch1==1:
try: mycursor.execute("select * from library_master") print("Current
record") print(tabulate(mycursor,headers=['Card No.','Name','Phone

No','Address','DOB'],tablefmt='psql'))
cardno=str(input("Enter card no:-"))
name_of_person=str(input("Enter new name:-"))
mycursor.execute("update library_master set
name_of_person='"+name_of_person+"' where
cardno='"+cardno+"'")
mydb.commit() print("Name has been updated")
mycursor.execute("select * from library_master")
print(tabulate(mycursor,headers=['Card No.','Name','Phone

No','Address','DOB'],tablefmt='psql')) except
Exception as e: print("Something went
wrong ",e)
#TO UPDATE PHONE NUMBER

if ch1==2:
try: mycursor.execute("select * from library_master") print("Current
record") print(tabulate(mycursor,headers=['Card No.','Name','Phone
No','Address','DOB'],tablefmt='psql')) cardno=str(input("Enter
card no:-")) phone_no=str(input("Enter new phone no:-"))
mycursor.execute("update library_master set
phone_no='"+phone_no+"' where cardno='"+cardno+"'")

mydb.commit() print("Number has been updated")


mycursor.execute("select * from library_master")
print(tabulate(mycursor,headers=['Card No.','Name','Phone

No','Address','DOB'],tablefmt='psql'))
except Exception as e: print("Something
went wrong ",e)
#TO UPDATE ADDRESS

if ch1==3: try: mycursor.execute("select * from library_master")


print("Current record") print(tabulate(mycursor,headers=['Card
No.','Name','Phone

No','Address','DOB'],tablefmt='psql'))
cardno=str(input("Enter card no:- "))
address=str(input("Enter new address:- "))
mycursor.execute("update library_master set address='"+address+"'
where cardno='"+cardno+"'")
mydb.commit() print("Address has been updated")
mycursor.execute("select * from library_master")
print(tabulate(mycursor,headers=['Card No.','Name','Phone

No','Address','DOB'],tablefmt='psql'))
except Exception as e: print("Something
went wrong ",e)

#TO UPDATE DATE OF BIRTH

if ch1==4:
try: mycursor.execute("select * from library_master") print("Current
record") print(tabulate(mycursor,headers=['Card No.','Name','Phone

No','Address','DOB'],tablefmt='psql'))
cardno=str(input("Enter card no:- "))
dob=str(input("Enter new date of birth(yyyy-mm-dd):"))
mycursor.execute("update library_master set dob='"+dob+"' where
cardno='"+cardno+"'")
mydb.commit() print("Date of birth has been updated")
mycursor.execute("select * from library_master")
print(tabulate(mycursor,headers=['Card No.','Name','Phone
No','Address','DOB'],tablefmt='psql')) except Exception as e:
print("Something went wrong ",e)
#TO UPDATE ALL DETAILS

if ch1==5:
try: mycursor.execute("select * from library_master")
print("Current record")
print(tabulate(mycursor,headers=['Card

No.','Name','Phone No','Address','DOB'],tablefmt='psql'))

cardno=str(input("Enter card no:-"))


name_of_person=str(input("Enter new name:- "))
mycursor.execute("update library_master set
name_of_person='"+name_of_person+"' where
cardno='"+cardno+"'") phone_no=str(input("Enter new
phone no:- ")) mycursor.execute("update
library_master set phone_no='"+phone_no+"' where
cardno='"+cardno+"'")

address=str(input("Enter new address:- ")) mycursor.execute("update


library_master set address='"+address+"' where cardno='"+cardno+"'")
dob=str(input("Enter new date of birth(yyyy-mm-dd):- "))
mycursor.execute("update library_master set dob='"+dob+"' where
cardno='"+cardno+"'") mydb.commit() print("Details have been updated")

mycursor.execute("select * from library_master")


print(tabulate(mycursor,headers=['Card No.','Name','Phone
No','Address','DOB'],tablefmt='psql'))
print("Updated Record") except Exception as e:

print("Something went wrong ",e)


#TO DELETE AN ACCOUNT

if ch==4:
try: mycursor.execute("select * from library_master") print("Accounts
Available") print(tabulate(mycursor,headers=['Card
No.','Name','Phone

No','Address','DOB'],tablefmt='psql'))
cardno=str(input("Enter card no:"))
mycursor.execute("delete from library_master where
cardno='"+cardno+"'")
mydb.commit() print("Removed succesfully")
mycursor.execute("select * from library_master")
print(tabulate(mycursor,headers=['Card No.','Name','Phone

No','Address','DOB'],tablefmt='psql')) except
Exception as e: print("Something went
wrong ",e)

#TO ADD NEW BOOK

if ch==5:
try: print("") print("FILL ALL BOOK DETAILS ") book_name=str(input("enter book
name:- ")) book_no=str(input("Enter no (limit 5 characters):- ")) genre=str(input("Enter
genre:- ")) authors_name=str(input("Enter the authors name (max 15 words):- "))
language=str(input("Enter the language of book:")) mycursor.execute("insert into books
values('"+book_name+"','"+book_no+"','"+genre+"','"+authors_name+"','"+language+"')")
print("Book added succesfully") mydb.commit() except Exception as e: print("Something
went wrong ",e)
#TO SEE BOOK DETAILS

if ch==6:
try:
book_no=str(input("Enter Book No:")) mycursor.execute("select *
from books where book_no='"+book_no+"'")
print(tabulate(mycursor,headers=['Book Name','book
Number','Genre','Authours

Name','Language'],tablefmt='psql'))
except Exception as e: print("Something
went wrong ",e)
#TO UPDATE BOOK DETAILS

if ch==7:
print("") print("press 1 to update Book
name") print("press 2 to update genre")
print("press 3 to update Author Name")
print("press 4 to update Language")
ch1=int(input("Enter your choice:"))

if ch1==1:
try: print("Current Books") mycursor.execute("select * from
books") print(tabulate(mycursor,headers=['Book Name','book
Number','Genre','Authours Name',

'Language'],tablefmt='psql'))
book_no=str(input("Enter bookno:- "))
name_of_book=str(input("Enter new name:- "))
mycursor.execute("update books set
book_name='"+name_of_book+"' where book_no='"+book_no+"'")
mydb.commit()
print("Name has been updated")
mycursor.execute("select * from books")
print(tabulate(mycursor,headers=['Book Name','book
Number','Genre','Authours
Name','Language'],tablefmt='psql')) except
Exception as e: print("Something went
wrong ",e)
#TO UPDATE GENRE

if ch1==2:
try: print("Current Record") mycursor.execute("select * from books")
book_no=str(input("Enter card no:")) genre=str(input("Enter new
genre:")) mycursor.execute("update books set genre='"+genre+"' where
book_no='"+book_no+"'") mydb.commit() print("*Genre has been
updated*") mycursor.execute("select * from books")
print(tabulate(mycursor,headers=['Book Name','book
Number','Genre','Authours Name','Language'],tablefmt='psql'))

except Exception as e: print("Something


went wrong ",e)

#TO UPDATE AUTHOR NAME

if ch1==3:
try: print("Current Record") mycursor.execute("select * from books")
book_no=str(input("Enter book no:")) author=str(input("Enter new
authors name:")) mycursor.execute("update books set
authors_name='"+author+"' where book_no='"+book_no+"'")
mydb.commit() print("*Authors name has been updated*")
mycursor.execute("select * from books")
print(tabulate(mycursor,headers=['Book Name','book

Number','Genre','Authours Name','Language'],tablefmt='psql'))

except Exception as e: print("Something went wrong ",e)


#TO UPDATE LANGUAGE

if ch1==4:
try: print("Current Record") mycursor.execute("select * from books")
book_no=str(input("Enter boom no:")) language=str(input("Enter new
language:")) mycursor.execute("update books set language='"+language+"'
where book_no='"+book_no+"'") mydb.commit() print("*Language has been
updated*") mycursor.execute("select * from books")
print(tabulate(mycursor,headers=['Book Name','book

Number','Genre','Authours Name','Language'],tablefmt='psql'))

except Exception as e: print("Something


went wrong ",e)
#TO UPDATE ALL DETAILS

if ch1==5:
try: print("Current Record") mycursor.execute("select * from
books") print(tabulate(mycursor,headers=['Book Name','book

Number','Genre','Authours
Name','Language'],tablefmt='psql')) book_no=str(input("Enter bookno:"))
name_of_book=str(input("Enter new name:")) mycursor.execute("update
books set book_name='"+name_of_book+"' where book_no='"+book_no+"'")

genre=str(input("Enter new genre:")) mycursor.execute("update books set


genre='"+genre+"' where book_no='"+book_no+"'") ) name:")authors new
author=str(input("Enter mycursor.execute("update books set
authors_name='"+author+"' where book_no='"+book_no+"'")
language=str(input("Enter new language:")) mycursor.execute("update books set
language='"+language+"' where

book_no='"+book_no+"'") mydb.commit()
mycursor.execute("select * from books")

print(tabulate(mycursor,headers=['Book Name','book
Number','Genre','Authours Name','Language'],tablefmt='psql'))

except Exception as e: print("Something


went wrong ",e)
#TO DELETE A BOOK

if ch==8:
try: print("Current Record") mycursor.execute("select *
from books") print(tabulate(mycursor,headers=['Book
Name','book

Number','Genre','Authours Name','Language'],tablefmt='psql'))
book_no=str(input("Enter book no:")) mycursor.execute("delete from books
where book_no='"+book_no+"'") mydb.commit() print("*Removed
succesfully*") mycursor.execute("select * from books")
print(tabulate(mycursor,headers=['Book Name','book

Number','Genre','Authours Name','Language'],tablefmt='psql'))

except Exception as e: print("Something


went wrong ",e)

#TO LEND A BOOK

if ch==9:
try: cardno=str(input("Enter card no:")) book_name=str(input("Enter the name of the
book:")) date_of_lend=str(input("Enter date of lending(yyyy-mm-dd)")) print("if book
not returned then enter(0000-00-00):") date_of_return=str(input("enter date of
return(yyyy-mm-dd):")) mycursor.execute("insert into library_transaction
values('"+cardno+"','"+book_name+"','"+date_of_lend+"','"+date_of_return+"')") except
Exception as e: print("Something went wrong ",e)
#TO RETURN A BOOK

if ch==10:
try: cardno=str(input("Enter card no:")) date_of_return=str(input("Enter date
of returning(yyyy-mm-dd):")) mycursor.execute("update library_transaction
set date_of_return='"+date_of_return+"' where cardno='"+cardno+"'")
mydb.commit() except Exception as e: print("Something went wrong ",e)

#TO SEE LENDING HISTORY

if ch==11:
cardno=str(input("Enter card no:"))
mycursor.execute("select * from library_transaction where
cardno='"+cardno+"'") print(tabulate(mycursor,headers=['Card Number','book
Number','Date of lend','Date of return'],tablefmt='psql'))

#TO EXIT THE PROGRAM

if ch==12:
print("Thank you :)")
break

else:
print("Enter correct input!!!")
OUTPUT
----------------------------------------------------------------------------------------------------
MAIN MENU
----------------------------------------------------------------------------------------------------
1 Create a new account
2 See the account info
3 Update card holder info
4 Delete the account
5 Add new book
6 See books
7 Update book details
8 Delete book
9 lend a book
10 return the book
11 display lending history
12 EXIT

#TO CREATE A LIBRARY ACCOUNT


enter your choice:- 1
FILL ALL PERSONAL DETAILS OF ACCOUNT HOLDER
enter card no: 1
Enter name (limit 30 characters): Hussain
Enter phone no: 9812345678
Enter the address (max 30 words): ABC colony
Enter the date of birth(yyyy-mm-dd): 2005-08-10
ACCOUNT IS SUCCESSFULLY CREATED!!!

enter your choice:- 1


FILL ALL PERSONAL DETAILS OF ACCOUNT HOLDER enter
card no: 2
Enter name (limit 30 characters): Abiali
Enter phone no: 9876543210
Enter the address (max 30 words): XYZ colony
Enter the date of birth(yyyy-mm-dd): 2005-06-18
ACCOUNT IS SUCCESSFULLY CREATED!!!
#TO SEE DETAILS OF CARD HOLDER
enter your choice:- 2
Enter card no:- 1
+------------+--------+------------+------------+------------+
| Card No. | Name | Phone No | Address | DOB |
|------------+--------+------------+------------+------------|
| 1 | Hussain | 9812345678 | ABC colony | 2005-08-10 |
+------------+--------+------------+------------+------------+

#TO UPDATE CARD HOLDER INFORMATION


enter your choice:- 3 press 1 to update name: press 2 to
update phone no: press 3 to update address: press 4 to
update date of birth: press 5 to update ALL the details:

Enter your choice:- 5

#TO UPDATE ALL DETAILS


Current record
+------------+----------+------------+------------+------------+
| Card No. | Name | Phone No | Address | DOB |
|------------+----------+------------+------------+------------|
| 1 | Hussain | 9812345678 | ABC colony | 2005-08-10 |
| 2 | Abiali | 9876543210 | XYZ colony | 2005-06-18 |
+------------+----------+------------+------------+------------+
Enter card no:-2
Enter new name:- Jai
Enter new phone no:- 9845672592
Enter new address:- ABC Colony
Enter new date of birth(yyyy-mm-dd):- 2005-11-23
Details have been updated
+------------+--------+------------+------------+------------+
| Card No. | Name | Phone No | Address | DOB |
|------------+--------+------------+------------+------------|
| 1 | Hussain | 9812345678 | ABC colony | 2005-08-10 |
| 2 | Hatim | 9845672592 | ABC Colony | 2005-11-23 |
+------------+--------+------------+------------+------------+
Updated Record
#TO DELETE AN ACCOUNT

Accounts Available
+------------+--------+------------+------------+------------+
| Card No. | Name | Phone No | Address | DOB |
|------------+--------+------------+------------+------------| 1
| | Hussain | 9812345678 | ABC colony | 2005-08-10 |
| 2 | Hatim | 9845672592 | ABC Colony | 2005-11-23 |
+------------+--------+------------+------------+------------+
Enter card no:1
Removed successfully
Remaining Records:-
+------------+--------+------------+------------+------------+
| Card No. | Name | Phone No | Address | DOB |
|------------+--------+------------+------------+------------|
| 2 +------------+--------+------------+------------+------------+
Abi| | 9845672592 | ABC Colony | 2005-11-23 |

#TO ADD NEW BOOK


enter your choice:- 5
FILL ALL BOOK DETAILS
enter book name:- Economics
Enter no (limit 5 characters):- 101
Enter genre:- Education
Enter the authors name (max 15 words):- Sl arora
Enter the language of book:English
Book added successfully.

#TO SEE BOOK DETAILS


enter your choice:- 6
Enter Book No:101
+-------------+---------------+-----------+-----------------+------------+
| Book Name | book Number | Genre | Authours Name | Language |
|-------------+---------------+-----------+-----------------+------------|
| Economics | 101 | Education | SandeepGarg | English |
+-------------+---------------+-----------+-----------------+------------+
#TO UPDATE BOOK DETAILS
enter your choice:- 7 press 1 to
update Book name press 2 to
update genre press 3 to update
Author Name press 4 to update
Language

#TO UPDATE ALL DETAILS


Enter your choice:5
Current Record
+-------------+---------------+-----------+-----------------+------------+
| Book Name | book Number | Genre | Authours Name | Language |
|-------------+---------------+-----------+-----------------+------------|
| Physics 101 | Education | Sl arora | English |
+-------------+---------------+-----------+-----------------+------------+
Enter bookno:101
Enter new name:Computer
Enter new genre:Education
Enter new authors name:Preeti aurora
Enter new language:English
+-------------+---------------+-----------+-----------------+------------+
| Book Name | book Number | Genre | Authours Name | Language |
|-------------+---------------+-----------+-----------------+------------|
| Computer | 101 | Education | Preeti aurora | English |
+-------------+---------------+-----------+-----------------+------------+

#TO DELETE A BOOK


enter your choice:- 8
Current Record
+-------------+---------------+-----------+-----------------+------------+
| Book Name | book Number | Genre | Authours Name | Language |
|-------------+---------------+-----------+-----------------+------------|
| Computer | 101 | Education | Preeti aurora | English |
+-------------+---------------+-----------+-----------------+------------+
Enter book no:101
*Removed succesfully*
+-------------+---------------+---------+-----------------+------------+
| Book Name | book Number | Genre | Authours Name | Language |
|-------------+---------------+---------+-----------------+------------|
+-------------+---------------+---------+-----------------+------------+
#TO LEND A BOOK
enter your choice:- 9
Enter card no:2
Enter the name of the book:Chemistry Enter date
of lending(yyyy-mm-dd)2022-10-20 if book not
returned then enter(0000-00-00): enter date of
return(yyyy-mm-dd):2022-11-25

#TO RETURN A BOOK


enter your choice:- 10
Enter card no:2
Enter date of returning(yyyy-mm-dd):2022-11-25

#TO SEE LENDING HISTORY


enter your choice:- 11
Enter card no:2
+---------------+---------------+----------------+------------------+
| Card Number | book Number | Date of lend | Date of return |
|---------------+---------------+----------------+------------------|
| 2 | Chemistry | 2022-10-20 | 2022-11-25 |
+---------------+---------------+----------------+------------------+

#TO EXIT THE PROGRAM


enter your choice:- 12
Thank you :)
BIBLIOGRAPHY

www.python.org
www.w3schools.com
www.pythonlobby.com
www.skoolbeep.com
www.programiz.com

You might also like