CS Proj Finallast
CS Proj Finallast
PROJECT
LIBRARY MANAGEMENT
SYSTEM
1
Shri Bhairavnath Shikshan Sanstha’s
Aditya English Medium School
Affiliation No. 1130831
Baner, Pune
Certificate
2
Acknowledgement
I would like to express my special thanks of gratitude to
my teacher
Varsha maam ,who gave me the golden opportunity to
do this wonderful project. For the subject Computer
science on Library management system
I am also thankful to our principal for supporting me. I
came to know about so many things.
I would also like to thank my parents who were very
supportive during this process. Thank you
Yours Faithfully
Shreyak Kadam
3
INDEX
Sr No Name Pg No
1 Introduction 5
2 Objective 6
3 Scope 7
4 Hardware/Software used 8
5 Theory 9
6 Flowchart 11
7 MySQL code 12
8 Python code 14
9 Output 22
10 User Manual 27
11 Pros and Cons 29
12 Conclusion 33
13 Bibliography 35
4
INTRODUCTION
5
Objective:
6
Scope:
7
HARDWARE USED
SOFTWARE USED
8
THEORY
What is Python?
9
interact with files, store data, and retrieve
information efficiently.
What is Database?
What is MySQL?
10
FLOWCHART
11
CODE
SOURCE CODE
For MySQL:
USE library_app;
12
issue_date DATE,
return_date DATE,
contact_email VARCHAR(50),
PRIMARY KEY (registration_name, bcode,
issue_date)
);
13
For Python:
import mysql.connector as a
from datetime import datetime, timedelta
def addbook():
bn = input("Enter Book Name: ")
ba = input("Enter Author's Name: ")
c = int(input("Enter Book Code (4-digit): "))
s = input("Enter Subject: ")
data = (bn, ba, c, s)
sql = 'INSERT INTO books (bname, author,
bcode, subject) VALUES (%s, %s, %s, %s);'
cursor = con.cursor()
cursor.execute(sql, data)
con.commit()
print("\nBook Added Successfully.\n")
input("Press enter to continue.....\n")
main()
def issueb():
n = input("Enter Student Name: ")
reg_name = input("Enter Registration Name: ")
14
email = input("Enter Contact Email Address: ")
co = int(input("Enter Book Code (4-digit): "))
issue_date = input("Enter Issue Date
(DD-MM-YYYY): ")
issue_date = datetime.strptime(issue_date,
'%d-%m-%Y').date()
return_date = issue_date + timedelta(days=7)
data = (n, reg_name, co, issue_date,
return_date, email)
a = "INSERT INTO issue (name,
registration_name, bcode, issue_date,
return_date, contact_email) VALUES (%s, %s, %s,
%s, %s, %s);"
cursor = con.cursor()
cursor.execute(a, data)
con.commit()
print(f"\nBook issued successfully to: {n}")
print(f"Return Date: {return_date}")
input('Press enter to continue.....\n')
bookup(co, -1)
main()
def returnb():
n = input("Enter Student Name: ")
reg_name = input("Enter Registration Name: ")
co = int(input("Enter Book Code (4-digit): "))
15
return_date = input("Enter Return Date
(DD-MM-YYYY): ")
return_date = datetime.strptime(return_date,
'%d-%m-%Y').date()
cursor = con.cursor()
cursor.execute("SELECT issue_date FROM
issue WHERE registration_name = %s AND bcode
= %s;", (reg_name, co))
result = cursor.fetchone()
if result:
issue_date = result[0]
expected_return_date = issue_date +
timedelta(days=7)
delta = (return_date -
expected_return_date).days
fine = 0
fine_details = ""
if delta > 0:
fine = 100 + ((delta - 1) // 3) * 50
fine_details = f"Fine Calculation:\nBase
Fine: 100 Rupees\nLate Days: {delta}\nAdditional
Fine: {((delta - 1) // 3) * 50} Rupees\nTotal Fine:
{fine} Rupees"
16
a = "INSERT INTO book_return (name,
registration_name, bcode, return_date, fine)
VALUES (%s, %s, %s, %s, %s);"
data = (n, reg_name, co, return_date, fine)
cursor.execute(a, data)
con.commit()
if fine > 0:
print(f"Book returned by: {n} with fine: {fine}
Rupees")
print(fine_details)
else:
print(f"Book returned by: {n} without any
fine.")
else:
print("No record found for the issued book.")
bookup(co, 1)
input("Press enter to continue.....\n")
main()
17
t = myresult[0] + u
sql = "UPDATE books SET total = %s WHERE
bcode = %s;"
cursor.execute(sql, (t, co))
con.commit()
input('Press enter to continue.....\n')
main()
def dbook():
ac = int(input("Enter Book Code (4-digit): "))
a = "DELETE FROM books WHERE bcode =
%s;"
cursor = con.cursor()
cursor.execute(a, (ac,))
con.commit()
print("Book deleted successfully")
input("Press enter to continue.....\n")
main()
def dispbook():
cursor = con.cursor()
cursor.execute("SELECT * FROM books;")
myresult = cursor.fetchall()
for i in myresult:
print(f"Book name: {i[0]}")
print(f"Author: {i[1]}")
18
print(f"Book code: {i[2]}")
print(f"Total: {i[3]}")
print(f"Subject: {i[4]}")
print('\n')
input('Press enter to continue.....\n')
main()
def report_issued_books():
cursor = con.cursor()
cursor.execute("SELECT * FROM issue;")
myresult = cursor.fetchall()
for i in myresult:
print(i)
input("Press enter to continue.....\n")
main()
def report_return_books():
cursor = con.cursor()
cursor.execute("SELECT * FROM
book_return;")
myresult = cursor.fetchall()
for i in myresult:
print(i)
input('Press enter to continue.....\n')
main()
19
def main():
print("""
LIBRARY MANAGEMENT APPLICATION
1. ADD BOOK
2. ISSUE OF BOOK
3. RETURN OF BOOK
4. DELETE BOOK
5. DISPLAY BOOKS
6. REPORT MENU
7. EXIT PROGRAM
""")
choice = input("Enter Task No: ")
if choice == '1':
addbook()
elif choice == '2':
issueb()
elif choice == '3':
returnb()
elif choice == '4':
dbook()
elif choice == '5':
dispbook()
elif choice == '6':
print("""
REPORT MENU
20
1. ISSUED BOOKS
2. RETURNED BOOKS
3. GO BACK TO MAIN MENU
""")
choice = input("Enter Task No: ")
if choice == '1':
report_issued_books()
elif choice == '2':
report_return_books()
elif choice == '3':
main()
else:
print("Please try again.")
main()
elif choice == '7':
print("Thank you and have a great day
ahead.")
else:
print("Please try again.")
main()
main()
21
OUTPUT
Add book:
22
Issue book:
23
If book returned on time:
24
Delete book and displaying new current books:
25
Issued books by users:
Exit:
26
USER MANUAL
Windows
1.Download Python:
○ Visit the official Python website.
○ Download the latest version for Windows.
2.Run the Installer:
○ Double-click the downloaded installer.
○ Check the box "Add Python to PATH" at
the bottom of the installation window.
○ Click "Install Now" and follow the prompts.
3.Verify Installation:
○ Open Command Prompt (cmd).
○ Type python --version and press
Enter. You should see the Python version
number.
27
○ Type pip --version to check if pip
(Python's package installer) is installed.
Windows
1.Download MySQL Installer:
○ Visit the MySQL website.
○ Download the MySQL Installer for
Windows.
2.Run the Installer:
○ Double-click the downloaded installer.
○ Choose the setup type: "Developer
Default" is recommended.
○ Follow the prompts to install MySQL and
MySQL Workbench.
3.Configure MySQL:
○ Set the root password during installation.
○ Complete the configuration wizard.
4.Verify Installation:
○ Open Command Prompt and type mysql
-u root -p, then enter the root
password to log in.
28
PROS AND CONS
Pros
1.Practical Application:
○ Provides hands-on experience with
database management and programming.
○ Useful for understanding CRUD (Create,
Read, Update, Delete) operations.
2.Skill Development:
○ Enhances skills in Python programming
and MySQL database management.
○ Provides exposure to integrating Python
with SQL databases.
3.Customizability:
○ Can be tailored to meet specific
requirements or extended with additional
features.
29
○ Easy to modify or expand, such as adding
new features or improving the user
interface.
4.Real-world Relevance:
○ Useful in real-world applications, as many
organizations use library management
systems.
○ Helps understand concepts used in actual
library management software.
5.Data Integrity:
○ Maintains data consistency through the
use of SQL transactions and queries.
○ Ensures accurate record-keeping for
books and transactions.
6.User Interaction:
○ Provides an opportunity to design user
interactions and handle input validation.
○ Offers a simple interface to interact with
the library database.
Cons
1.Limited User Interface:
○ The project relies on command-line input,
which can be less user-friendly compared
to graphical user interfaces (GUIs).
30
○ Limited visual appeal and may not be
suitable for users unfamiliar with
command-line operations.
2.Basic Functionality:
○ Lacks advanced features like search
functionality, user authentication, and
advanced reporting.
○ May require additional development to
handle more complex requirements.
3.Scalability Issues:
○ Designed for small-scale use; may not
perform well with large volumes of data or
users.
○ May need optimization for performance
and scalability in a production
environment.
4.Error Handling:
○ Basic error handling might not cover all
possible issues, leading to potential
crashes or data inconsistencies.
○ Requires careful validation of inputs and
handling of edge cases.
5.Security Concerns:
○ Basic implementation may lack robust
security measures, such as data
encryption or secure user authentication.
31
○ Potential risks if sensitive data is not
properly secured.
6.Maintenance:
○ Requires ongoing maintenance to fix bugs
and update the code as needed.
○ May require periodic updates to ensure
compatibility with new versions of Python
or MySQL.
32
CONCLUSION
33
The Library Management System project shows
how to use Python and MySQL to manage books
and transactions. It helps you learn about adding,
issuing, returning, and deleting books from a
database. Although the system works well for
small-scale use, there’s room to add more features
like a user-friendly interface and better error
handling. This project provides practical
experience with programming and databases, and
it’s a good start for understanding how these
technologies work together. Improving the system
with new features and better security can make it
more useful and reliable.
34
BIBLIOGRAPHY
35