Project File (1) (1) Python
Project File (1) (1) Python
1
Acknowledgement
I wish to express my deepest gratitude to my Computer Science teacher
Ms. Ekta Bajaj whose intellectual guidance, kind co-operation and everlasting
patience became a milestone in preparing this project. I have indeed short
words to give adequate expression.
I am also thankful to my parents and friends whose valuable help and ideas
made this project a success.
2
Certificate
It is further added that it is record of his own work carried out under my
guidance and project has been completed successfully.
_______________
3
Table of Contents
Acknowledgement----------------------------------------------------------------------------------------- 2
Certificate --------------------------------------------------------------------------------------------------- 3
Chapter -1 : Introduction to Project-------------------------------------------------------------------- 5
1.1 Proposed System --------------------------------------------------------------------------------- 5
1.2 Operating Environment ------------------------------------------------------------------------- 6
Chapter -2: Database related to Project --------------------------------------------------------------- 7
2.1 Table 1: Person_details ------------------------------------------------------------------------- 7
2.2 Table 2: card_details ----------------------------------------------------------------------------- 7
2.3 Table 3: person_card_details ------------------------------------------------------------------- 7
2.4 Table 4: Book_details ---------------------------------------------------------------------------- 8
2.5 Table 5: Issued Books --------------------------------------------------------------------------- 8
Chapter -3: Python Code of Project -------------------------------------------------------------------- 9
3.1 Index.py -------------------------------------------------------------------------------------------- 9
3.2 Person.py ---------------------------------------------------------------------------------------- 11
3.3 Book.py------------------------------------------------------------------------------------------- 11
3.4 Card.py ------------------------------------------------------------------------------------------- 14
3.5 Fine.py-------------------------------------------------------------------------------------------- 16
3.6 Sqltables.py-------------------------------------------------------------------------------------- 17
Chapter -4 : Implementation of Project ------------------------------------------------------------- 19
Chapter -5: Future Scope ------------------------------------------------------------------------------- 22
Chapter -6: Bibliography ------------------------------------------------------------------------------- 23
4
Chapter -1 : Introduction to Project
Librarian can use it to manage the library using a computerized system where
he/she can record various transactions like issue of books, return of books, addition
of new books, addition of new students etc.
It would keep track of the students using the library and also a detailed description
about the books a library contains. With this computerized system there will be no
loss of book record or member record which generally happens when a non-
computerized system is used.
This would be able to help librarian to manage the library with more convenience
and in a more efficient way as compared to library systems which are not
computerized.
The proposed system, will be able to perform the following functions in the
computerized way:
5
1.2 Operating Environment:
The specifications of Hardware and Software used are given in the following table:
Ram 4 GB
Database My SQL
6
Chapter -2: Database related to Project
7
2.4 Table 4: Book_details
8
Chapter -3: Python Code of Project
3.1 Index.py
connection=sql.connect(host="localhost",user="root",passwd="12345",auth_plugin='mys
ql_native_password',database="library")
#sql_tables.create_tables(connection)
print('enter 1 to view our card details')
print('enter 2 to enter new card type details')
print('enter 3 to enter a new person details')
print('enter 4 to issue a new card to person')
print('enter 5 to enter a new book details')
print('enter 6 to search for a book')
print('enter 7 to issue a book to a person')
print('enter 8 to view issued books to a person')
print('enter 9 to return an issued book')
print('enter 10 to view fine of a person')
print('enter 11 to collect fine')
print('enter 12 to view Person card details')
print('enter 13 to exit')
print('enter 0 to view menu again')
while True:
elif ch==5:
Book.new_book_record(connection)
elif ch==2:
Card.new_card_details(connection)
9
elif ch==4:
Card.issue_card(connection)
elif ch==7:
Book.issue_book(connection)
elif ch==9:
Book.return_book(connection)
elif ch==10:
fine.view_fine(connection)
elif ch==11:
fine.collect_fine(connection)
elif ch==8:
Book.view_issued_books(connection)
elif ch==1:
Card.view_library_cards(connection)
elif ch==12:
Card.view_person_card(connection)
elif ch==6:
Book.search_books(connection)
elif ch==13:
break
elif ch==0:
print('enter 1 to view our card details')
print('enter 2 to enter new card type details')
print('enter 3 to enter a new person details')
print('enter 4 to issue a new card to person')
print('enter 5 to enter a new book details')
print('enter 6 to search for a book')
print('enter 7 to issue a book to a person')
print('enter 8 to view issued books to a person')
print('enter 9 to return an issued book')
print('enter 10 to view fine of a person')
print('enter 11 to collect fine')
print('enter 12 to view Person card details')
10
print('enter 13 to exit')
print('enter 0 to view menu again')
connection.commit()
print('thankyou for using our system.')
3.2 Person.py
def new_person_record(conn):
cursor=conn.cursor()
name=input("enter the name")
fname=input("enter the father name")
dob=input("enter the date of birth in format yyyy-mm-dd")
uid=int(input("enter the aadhar id"))
address=input("enter the address")
phone=int(input("enter the phone number"))
gender=input("enter the gender (M/F)")
post=input("enter the post of person")
cursor.execute(query.format(last_id+1,name,fname,dob,uid,address,phone,gender,p
ost))
print(cursor.rowcount,"records inserted with person ID", last_id+1)
3.3 Book.py
11
def new_book_record(conn):
cursor=conn.cursor()
title=input("enter the title of the book")
subject=input("enter the subject")
author=input("enter the author")
year=int(input("enter the year of publish"))
publisher=input("enter the publisher's name")
rack=int(input("enter the rack number where book will be kept"))
def issue_book(conn):
cursor=conn.cursor()
pid=int(input("enter the issuer id "))
bid=int(input("enter the book id"))
stmt1='select card_id, due_date from person_card_details where Person_id={}'
cursor.execute(stmt1.format(pid))
row1=cursor.fetchone()
if cursor.rowcount==0:
print('sorry! No such person exists')
return
stmt2='select count(*) from issued_books where Book_id={} and
date_of_return="1000-01-01"'
cursor.execute(stmt2.format(bid))
row2=cursor.fetchone()
print(row2)
if row2[0]>0:
print('Book already issued to someone')
return
12
stmt3='select count(*) from issued_books where date_of_return is null and
Person_id={}'
cursor.execute(stmt3.format(pid))
row3=cursor.fetchone()
if row3[0]==row4[0]:
print('limit of books issued already reached')
return
def return_book(conn):
cursor=conn.cursor()
bid=int(input("enter the book id"))
stmt1='select Person_id,datediff(curdate(),date_of_due) as no_of_days from
issued_books where Book_id={} and date_of_return is null'
cursor.execute(stmt1.format(bid))
row1=cursor.fetchone()
13
stmt3='update issued_books set date_of_return=curdate() where Book_id={}'
cursor.execute(stmt3.format(bid))
print(cursor.rowcount,"book returned")
if row1[1]>0:
stmt4='update Person_details set fine_balance={}*{} where Person_id={}'
cursor.execute(stmt4.format(row1[1],row2[0],row1[0]))
print(cursor.rowcount,"person was issued fine")
def view_issued_books(conn):
cursor=conn.cursor()
pid=int(input("enter the Person id"))
stmt3='select Book_id,Book_title,book_author from issued_books natural join
Book_details where Person_id={} and date_of_return="1000-01-01"'
cursor.execute(stmt3.format(pid))
row3=cursor.fetchall()
for i in row3:
print(i[0],i[1],' by ', i[2])
if cursor.rowcount==0:
print('No books issued to this id')
def search_books(conn):
cursor=conn.cursor()
title=input("enter the title")
stmt3='select Book_id,Book_title,book_author,rack from Book_details where book_title
like "%{}%"'
cursor.execute(stmt3.format(title))
row3=cursor.fetchall()
for i in row3:
print(i[0],i[1],' by ', i[2],'at rack no',i[3])
if cursor.rowcount==0:
print('sorry! No book matched your title')
3.4 Card.py
def new_card_details(conn):
14
cursor=conn.cursor()
title=input("enter the title of the Card")
books_limit=input("enter the limit of books which can be issued")
days_limit=input("enter the number of days for which books are issued")
fine_per_day=int(input("enter the amount of fine per day"))
def issue_card(conn):
cursor=conn.cursor()
Person_id=input("enter the ID OF PERSON")
Card_Id=input("enter the card type - ID")
def view_library_cards(conn):
cursor=conn.cursor()
stmt1='select * from Card_details'
cursor.execute(stmt1)
rows=cursor.fetchall()
print('SN','\t','title','\t\t','books','\t','days','\t','fine')
for i in rows:
print(i[0],'\t',i[1],'\t',i[2],'\t',i[3],'\t',i[4])
if cursor.rowcount==0:
15
print('sorry! No cards exist for now')
def view_person_card(conn):
cursor=conn.cursor()
pid=input("enter the ID OF PERSON")
stmt1='select Person_id,card_title,issue_date,due_date from Person_Card_details
natural join Card_details where Person_id={}'
cursor.execute(stmt1.format(pid))
rows=cursor.fetchall()
print('Person','\t','Card','\t','Issue_date','\t','Due_date')
for i in rows:
print(i[0],'\t',i[1],'\t',i[2],'\t',i[3])
if cursor.rowcount==0:
print('sorry! No card issued to this id')
3.5 Fine.py
def collect_fine(conn):
cursor=conn.cursor()
pid=input("enter the ID OF PERSON")
amt=input("enter the amount")
query="update Person_details set fine_balance=fine_balance-{} where Person_id={}"
cursor.execute(query.format(amt,pid))
if cursor.rowcount==1:
print("fine collected")
def view_fine(conn):
cursor=conn.cursor()
pid=input("enter the ID OF PERSON")
query="select fine_balance from Person_details where Person_id={}"
cursor.execute(query.format(pid))
print(cursor.fetchone()[0],"Rs")
16
3.6 Sqltables.py
def create_tables(conn):
#table Person
table_person="create table Person_details(Person_id integer primary key,Person_name
varchar(50) not null,father_name varchar(50),date_of_birth date,AADHAR bigint,\
address varchar(50),phone_no bigint,gender char(1),post varchar(15),fine_balance int
default 0);"
#table books
table_book="create table Book_details(Book_id integer primary key,book_title
varchar(50) not null,subject varchar(50),book_author varchar(50),year int,\
publisher varchar(50),rack integer);"
#table Cards
table_cards="create table card_details(Card_id integer primary key,Card_title
varchar(50) not null,no_of_books tinyint,no_of_days tinyint,\
fine_per_day tinyint);"
#issue cards
table_issue_card="create table person_card_details(Person_id integer primary key,
card_id integer not null,issue_date date,due_date date);"
#issue books
table_issue_book="create table Issued_books(Issue_id integer primary key,Person_id
integer,Book_id integer,date_of_issue date,date_of_due date,date_of_return date)"
cursor=conn.cursor()
cursor.execute(table_book);
cursor.execute(table_person);
cursor.execute(table_cards);
cursor.execute(table_login);
cursor.execute(table_issue_card);
17
cursor.execute(table_issue_book);
cursor.execute(table_transactions);
18
Chapter -4 : Implementation of Project
➢ Start
enter 1 to view our card details
enter 2 to enter new card type details
enter 3 to enter a new person details
enter 4 to issue a new card to person
enter 5 to enter a new book details
enter 6 to search for a book
enter 7 to issue a book to a person
enter 8 to view issued books to a person
enter 9 to return an issued book
enter 10 to view fine of a person
enter 11 to collect fine
enter 12 to view Person card details
enter 13 to exit
enter 0 to view menu again
enter your choice
➢ Choice 1
enter your choice1
SN title books days fine
1 Silver 3 15 2
2 Golden 4 3 3
3 Platinum 2 30 5
➢ Choice 2
enter your choice2
enter the title of the CardDiamond
enter the limit of books which can be issued4
enter the number of days for which books are issued60
enter the amount of fine per day7
1 card type created
➢ Choice 3
enter your choice3
enter the nameMohan
enter the father nameRajinder
enter the date of birth in format yyyy-mm-dd193-07-07
enter the aadhar id653387643228
enter the addressSaharanpur
enter the phone number7548990545
enter the gender (M/F)M
enter the post of personVisitor
1 records inserted with person ID 10004
➢ Choice 4
19
enter your choice4
enter the ID OF PERSON10004
enter the card type - ID1
1 card issued
➢ Choice 5
enter your choice5
enter the title of the bookThe child Called It
enter the subjectNovel
enter the authorHarry
enter the year of publish2000
enter the publisher's nameBPB
enter the rack number where book will be kept5
1 records inserted with Book id 1005
➢ Choice 6
enter your choice6
enter the titleChild
1005 The child Called It by Harry at rack no 5
➢ Choice 7
enter your choice7
enter the issuer id 10004
enter the book id1005
1 book issued
➢ Choice 8
enter your choice8
enter the Person id10004
1005 The child Called It by Harry
➢ Choice 9
enter your choice9
enter the book id1005
1 book returned
➢ Choice 10
enter your choice10
enter the ID OF PERSON10001
1 Rs
➢ Choice 11
enter your choice11
enter the ID OF PERSON10001
enter the amount1
fine collected
➢ Choice 12
enter your choice12
enter the ID OF PERSON10004
Person Card Issue_date Due_date
10004 Silver 2023-01-17 2024-01-17
20
➢ Choice 13
thankyou for using our system.
➢ Choice 0
enter 1 to view our card details
enter 2 to enter new card type details
enter 3 to enter a new person details
enter 4 to issue a new card to person
enter 5 to enter a new book details
enter 6 to search for a book
enter 7 to issue a book to a person
enter 8 to view issued books to a person
enter 9 to return an issued book
enter 10 to view fine of a person
enter 11 to collect fine
enter 12 to view Person card details
enter 13 to exit
enter 0 to view menu again
21
Chapter -5: Future Scope
Although Our system is useful in performing the library works computerized. But as
said, any computer system is not complete in itself. There is always a future scope.
22
Chapter -6: Bibliography
3. Internet
23