Libsys Proj Xii 2024-25-1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Central Board of Secondary Education

New Delhi

&

Techno India Group Public School, Siliguri


Affiliated with Central Board of Secondary Education, New Delhi
Affiliation Number: 2430126 | School Code: 15735
Address: SIT Campus, Hill Cart Road, P. O. Sukna, City: Siliguri
Dist.: Darjeeling, State: West Bengal, PIN: 734009

Project File
Project Title: Library Management System

Submitted to: Department of Computer Science

For the partial fulfillment of AISSCE Examination for the Academic Session: 2024-25

SUBMITTED BY

Name :
Class : XII
Stream : SCIENCE
Roll No. :
ID SHEET

Roll No. :

Name of the Student :

Supervisor : Bikramadittya Bagchi

Project Title : Library Management System

Front End Tool : Python (Latest Version)

Backend Tool : MySQL 8.0

Page |2
CERTIFICATE

This is to certify that ___________________________________________________________________________________

of Class XII Science of Techno India Group Public School, Siliguri has done his project titled on Library

Management System (Digital Library) under my supervision.

The student has taken a keen interest and has shown utmost sincerity in completing the project.

I certify that this project is up to my expectation and as per the guidelines issued by Central Board

of Secondary Education, New Delhi.

INTERNAL EXAMINER EXTERNAL EXAMINER

PRINCIPAL

Page |3
ACKNOWLEDGEMENT

It is with pleasure that I acknowledge my sincere gratitude to our teacher, Mr. Bikramadittya

Bagchi, PGT (Computer Science) who taught and undertook responsibility for teaching the subject

computer science. I have greatly benefited from his classes.

I am especially indebted to our Principal Dr. Nandita Nandi who has always been a source of

encouragement and support and without whose inspiration this project would not have been

successful I would like to place on record heartfelt thanks to her.

Finally, I would like to express my sincere appreciation for all the other students for my batch their

friendship & the fine time that we all shared together.

Signature

Page |4
CONTENTS

ID SHEET................................................................................................................................................................................. 2

Certificate ............................................................................................................................................................................... 3

Acknowledgement ............................................................................................................................................................. 4

Hardware and Software Requirements ....................................................................................................................... 6

Hardware ........................................................................................................................................................................... 6

Software ............................................................................................................................................................................. 6

Introduction .......................................................................................................................................................................... 7

Library ..................................................................................................................................................................................... 8

Library Management System .......................................................................................................................................... 9

Purpose .............................................................................................................................................................................. 9

Usage .................................................................................................................................................................................. 9

Code ..................................................................................................................................................................................... 11

Output.................................................................................................................................................................................. 20

Python Interface ........................................................................................................................................................... 20

Database ......................................................................................................................................................................... 24

Bibliography....................................................................................................................................................................... 26

Page |5
HARDWARE AND SOFTWARE REQUIREMENTS

Hardware
1. Desktop Computer/Laptop

2. Mobile Phone

Software
1. Python (Latest Version)

a. MySQL-Connector-Python

b. Pandas

2. MySQL

Page |6
INTRODUCTION

The project LIBRARY MANAGEMENT SYSTEM (DIGITAL LIBRARY) includes enrolment of users,

adding books into the library system. It includes an authentication facility for admin and users to log

in into the admin panel and the user panel resp. of the system. Users can see the books available,

details of books issued by the user in the digital library. The Library Management System can login

using a user ID and password. It is accessible either by an admin or user. Only the admin can add,

delete and update the data of users and books into the database. The data can be retrieved easily.

The interface is very user-friendly. The data is well protected for personal use and processes
the data very fast.

The purpose of the project entitled as “DIGITAL LIBRARY” is to computerize the Front Library

Management to develop software, which is user friendly, simple, fast, and cost- effective. It also has

a notes facility where the user can add notes at any point of the program into the database.

Page |7
LIBRARY

A library is a collection of books, and possibly other materials and media, that is accessible for use

by its members and members of allied institutions. Libraries provide physical or digital materials,

and maybe a physical location, a virtual space, or both. A library's collection normally includes

printed materials which may be borrowed, and usually also includes a reference section of

publications which may only be utilized inside the premises.

Libraries can vary widely in size and may be organized and maintained by a public body such as a

government, an institution (such as a school or museum), a corporation, or a private individual. In

addition to providing materials, libraries also provide the services of librarians who are trained

experts in finding, selecting, circulating and organizing information while interpreting information

needs and navigating and analyzing large amounts of information with a variety of resources.

Page |8
LIBRARY MANAGEMENT SYSTEM

Digital Library

Library Management System (LMS), is an enterprise resource planning system for a library, used

to track enrolled users, available books, books issued and to whom, books returned and its fines,

etc.

Purpose

The purpose of a library management system is to operate a library efficiently and at reduced costs.

The system, being entirely automated, streamlines all the tasks involved in operations of the library.

Usage

The library management system helps with reducing operational costs. Managing a library manually

is labor intensive and an immense amount of paperwork is involved. The system saves time for both

the user and the librarian. With just a click the user can search for books available in the library. The

librarian can answer queries with ease regarding the availability of books. Adding, removing or

editing the database is a simple process. Adding new users or cancelling existing userships can be

done with ease. The automated system saves a considerable amount of time as opposed to the

manual system.

Page |9
PYTHON CODE

P a g e | 10
CODE

File: library_manager_functions.py

import mysql.connector
from mysql.connector import errorcode
import pandas as pd

# Database configuration
config = {
'user': 'root',
'passwd': '1234',
'host': 'localhost',
'auth_plugin':'mysql_native_password'
}

def initialize_database():
"""Create the LibraryDB database and necessary tables if they don't exist."""
try:
# Connect to MySQL
conn = mysql.connector.connect(**config)
cursor = conn.cursor()

# Create Database
cursor.execute("CREATE DATABASE IF NOT EXISTS LibraryDB")
cursor.execute("USE LibraryDB")

# Create Users Table


cursor.execute("""
CREATE TABLE IF NOT EXISTS Users (
user_id INT PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(50) NOT NULL,
role ENUM('admin', 'user') DEFAULT 'user'
)
""")

cursor.execute('''
INSERT IGNORE INTO USERS (user_id, username, password, role)
VALUES (1, 'admin', 12345, 'admin');
''')

# Create Books Table


cursor.execute("""
CREATE TABLE IF NOT EXISTS Books (
book_id INT PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
author VARCHAR(255) NOT NULL,
genre VARCHAR(100),
publish_year INT,
isbn VARCHAR(13),
status ENUM('available', 'borrowed') DEFAULT 'available'
)
""")

# Create IssuedBooks Table


cursor.execute("""
CREATE TABLE IF NOT EXISTS IssuedBooks (
issue_id INT PRIMARY KEY AUTO_INCREMENT,
book_id INT,
user_id INT,
issue_date DATETIME DEFAULT CURRENT_TIMESTAMP,
return_date DATE,
FOREIGN KEY (book_id) REFERENCES Books(book_id),
FOREIGN KEY (user_id) REFERENCES Users(user_id)
)

P a g e | 11
""")

print("Database and tables are ready.")


except mysql.connector.Error as err:
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("Invalid username or password")
else:
print(f"Error: {err}")
finally:
cursor.close()
conn.close() if 'conn' in locals() else None

def connect():
"""Connect to the LibraryDB database."""
config_with_db = config.copy()
config_with_db['database'] = 'LibraryDB'

try:
conn = mysql.connector.connect(**config_with_db)
if conn.is_connected():
print("Connected to LibraryDB.")
return conn
except mysql.connector.Error as e:
print(f"Error: {e}")
return None

def authenticate(username, password):


"""Authenticate user and return user details if successful."""
conn = connect()
if conn is None:
return None

cursor = conn.cursor(dictionary=True)
try:
query = "SELECT * FROM Users WHERE username = %s AND password = %s"
cursor.execute(query, (username, password))
user = cursor.fetchone()

if user:
print(f"Welcome, {user['username']} ({user['role']})!")
return user
else:
print("Invalid username or password.")
return None
except mysql.connector.Error as e:
print(f"Error: {e}")
finally:
cursor.close()
conn.close()

def add_user(conn, username, password, role='user'):


"""Add a new user."""
cursor = conn.cursor()
query = "INSERT INTO Users (username, password, role) VALUES (%s, %s, %s)"
try:
cursor.execute(query, (username, password, role))
conn.commit()
print(f"User '{username}' added successfully.")
except mysql.connector.Error as err:
print(f"Error: {err}")
finally:
cursor.close()

def delete_user(conn, user_id):


"""Delete a user by user_id."""
cursor = conn.cursor()
query = "DELETE FROM Users WHERE user_id = %s"
try:
cursor.execute(query, (user_id,))

P a g e | 12
conn.commit()
print(f"User ID {user_id} deleted successfully.")
except mysql.connector.Error as err:
print(f"Error: {err}")
finally:
cursor.close()

def update_user(conn, user_id, username=None, password=None, role=None):


"""Update an existing user if they exist."""
cursor = conn.cursor()

try:
# Check if the user exists
cursor.execute("SELECT * FROM Users WHERE user_id = %s", (user_id,))
user = cursor.fetchone()

if not user:
print(f"User ID {user_id} not found. Update operation aborted.")
return # Exit the function if user does not exist

# Prepare fields to update


updates = []
values = []

if username:
updates.append("username = %s")
values.append(username)
if password:
# If necessary, we can use password hashing here for better security (e.g., hashlib)
updates.append("password = %s")
values.append(password)
if role:
updates.append("role = %s")
values.append(role)

# Execute the update only if there are fields to update


if updates:
query = f"UPDATE Users SET {', '.join(updates)} WHERE user_id = %s"
values.append(user_id)
cursor.execute(query, values)
conn.commit()
print(f"User ID {user_id} updated successfully.")
else:
print("No fields provided to update.")

except mysql.connector.Error as err:


print(f"Error: {err}")
conn.rollback() # Roll back any changes in case of error

finally:
cursor.close()

def display_users(conn):
"""Display all users."""
cursor = conn.cursor(dictionary=True)
try:
cursor.execute("SELECT user_id, username, role FROM Users")
users = cursor.fetchall()
df = pd.DataFrame(users)
print("Users:")
print(df.to_string(index=False))
except mysql.connector.Error as e:
print(f"Error: {e}")
finally:
cursor.close()

P a g e | 13
def search_user(conn, **kwargs):
"""Search for users based on specified fields."""
cursor = conn.cursor(dictionary=True)
conditions = []
values = []
for field, value in kwargs.items():
conditions.append(f"{field} LIKE %s")
values.append(f"%{value}%")

query = "SELECT user_id, username, role FROM Users WHERE " + " AND ".join(conditions)
try:
cursor.execute(query, values)
users = cursor.fetchall()
df = pd.DataFrame(users)
print("Search Results:")
print(df.to_string(index=False))
except mysql.connector.Error as e:
print(f"Error: {e}")
finally:
cursor.close()

def add_book(conn, title, author, genre, publish_year, isbn):


"""Add a new book."""
cursor = conn.cursor()
query = "INSERT INTO Books (title, author, genre, publish_year, isbn) VALUES (%s, %s, %s, %s, %s)"
try:
cursor.execute(query, (title, author, genre, publish_year, isbn))
conn.commit()
print(f"Book '{title}' added successfully.")
except mysql.connector.Error as err:
print(f"Error: {err}")
finally:
cursor.close()

def delete_book(conn, book_id):


"""Delete a book by book_id."""
cursor = conn.cursor()
query = "DELETE FROM Books WHERE book_id = %s"
try:
cursor.execute(query, (book_id,))
conn.commit()
print(f"Book ID {book_id} deleted successfully.")
except mysql.connector.Error as err:
print(f"Error: {err}")
finally:
cursor.close()

def update_book(conn, book_id, title=None, author=None, genre=None, publish_year=None, isbn=None):


"""Update an existing book."""
cursor = conn.cursor()
updates = []
values = []

if title:
updates.append("title = %s")
values.append(title)
if author:
updates.append("author = %s")
values.append(author)
if genre:
updates.append("genre = %s")
values.append(genre)
if publish_year:
updates.append("publish_year = %s")
values.append(publish_year)
if isbn:
updates.append("isbn = %s")
values.append(isbn)

P a g e | 14
if updates:
query = f"UPDATE Books SET {', '.join(updates)} WHERE book_id = %s"
values.append(book_id)
try:
cursor.execute(query, values)
conn.commit()
print(f"Book ID {book_id} updated successfully.")
except mysql.connector.Error as err:
print(f"Error: {err}")
else:
print("No fields provided to update.")

cursor.close()

def issue_book(conn, book_id, user_id):


"""Issue a book to a user."""
cursor = conn.cursor()
try:
# Check if book is available
cursor.execute("SELECT status FROM Books WHERE book_id = %s", (book_id,))
book_status = cursor.fetchone()

if book_status and book_status[0] == 'available':


query = "INSERT INTO IssuedBooks (book_id, user_id) VALUES (%s, %s)"
cursor.execute(query, (book_id, user_id))
cursor.execute("UPDATE Books SET status = 'borrowed' WHERE book_id = %s", (book_id,))
conn.commit()
print(f"Book ID {book_id} issued to User ID {user_id}.")
else:
print("Book is not available.")
except mysql.connector.Error as e:
print(f"Error: {e}")
finally:
cursor.close()

def return_book(conn, book_id, user_id):


"""Return a book by updating the IssuedBooks and Books tables."""
cursor = conn.cursor()
try:
# Check if the book is issued to this user
query = "SELECT issue_id FROM IssuedBooks WHERE book_id = %s AND user_id = %s AND return_date IS
NULL"
cursor.execute(query, (book_id, user_id))
issue_record = cursor.fetchone()

if issue_record:
# Update the return date and book status
cursor.execute("UPDATE IssuedBooks SET return_date = CURRENT_DATE WHERE issue_id = %s",
(issue_record[0],))
cursor.execute("UPDATE Books SET status = 'available' WHERE book_id = %s", (book_id,))
conn.commit()
print(f"Book ID {book_id} returned by User ID {user_id}.")
else:
print("No active record found for this book and user.")
except mysql.connector.Error as e:
print(f"Error: {e}")
finally:
cursor.close()

def display_books(conn):
"""Display all available books."""
cursor = conn.cursor(dictionary=True)
try:
query = "SELECT * FROM Books WHERE status = 'available'"
cursor.execute(query)
books = cursor.fetchall()
df = pd.DataFrame(books)
print("Available Books:")
print(df.to_string(index=False))

P a g e | 15
except mysql.connector.Error as e:
print(f"Error: {e}")
finally:
cursor.close()

def search_books(conn, **kwargs):


"""Search books by given criteria."""
conditions = []
values = []
for field, value in kwargs.items():
conditions.append(f"{field} LIKE %s")
values.append(f"%{value}%")

query = "SELECT * FROM Books WHERE " + " AND ".join(conditions) + " AND status = 'available'"
cursor = conn.cursor(dictionary=True)
try:
cursor.execute(query, values)
books = cursor.fetchall()
df = pd.DataFrame(books)
print("Search Results:")
print(df.to_string(index=False))
except mysql.connector.Error as e:
print(f"Error: {e}")
finally:
cursor.close()

def issued_books_details(conn, user_id):


"""Display all books issued to the logged-in user."""
query = """
SELECT Books.book_id, Books.title, Books.author, IssuedBooks.issue_date, IssuedBooks.return_date
FROM IssuedBooks
JOIN Books ON IssuedBooks.book_id = Books.book_id
WHERE IssuedBooks.user_id = %s
"""
cursor = conn.cursor(dictionary=True)
try:
cursor.execute(query, (user_id,))
issued_books = cursor.fetchall()
df = pd.DataFrame(issued_books)
print("Issued Book Details:")
print(df.to_string(index=False))
except mysql.connector.Error as e:
print(f"Error: {e}")
finally:
cursor.close()

File: main.py

from library_manager_functions import (


initialize_database, connect, authenticate,
add_user, delete_user, update_user, display_users, search_user,
add_book, delete_book, update_book, issue_book, return_book,
display_books, search_books, issued_books_details
)

def admin_menu(conn):
"""Admin menu with options for user and book management."""
while True:
print("\nAdmin Menu:")
print("1. Add User")
print("2. Delete User")
print("3. Update User")
print("4. Display Users")
print("5. Search Users")
print("6. Add Book")

P a g e | 16
print("7. Delete Book")
print("8. Update Book")
print("9. Issue Book")
print("10. Return Book")
print("11. Display All Books")
print("12. Search Books")
print("13. Log Out")

choice = input("Enter your choice: ")

if choice == '1':
username = input("Enter username: ")
password = input("Enter password: ")
role = input("Enter role (admin/user): ")
add_user(conn, username, password, role)

elif choice == '2':


user_id = int(input("Enter User ID to delete: "))
delete_user(conn, user_id)

elif choice == '3':


user_id = int(input("Enter User ID to update: "))
username = input("New username (leave blank to skip): ") or None
password = input("New password (leave blank to skip): ") or None
role = input("New role (leave blank to skip): ") or None
update_user(conn, user_id, username, password, role)

elif choice == '4':


display_users(conn)

elif choice == '5':


field = input("Enter field to search by (username/role): ")
value = input(f"Enter {field} value to search for: ")
search_user(conn, **{field: value})

elif choice == '6':


title = input("Enter book title: ")
author = input("Enter author: ")
genre = input("Enter genre: ")
publish_year = int(input("Enter publish year: "))
isbn = input("Enter ISBN: ")
add_book(conn, title, author, genre, publish_year, isbn)

elif choice == '7':


book_id = int(input("Enter Book ID to delete: "))
delete_book(conn, book_id)

elif choice == '8':


book_id = int(input("Enter Book ID to update: "))
title = input("New title (leave blank to skip): ") or None
author = input("New author (leave blank to skip): ") or None
genre = input("New genre (leave blank to skip): ") or None
publish_year = input("New publish year (leave blank to skip): ")
isbn = input("New ISBN (leave blank to skip): ") or None
publish_year = int(publish_year) if publish_year else None
update_book(conn, book_id, title, author, genre, publish_year, isbn)

elif choice == '9':


book_id = int(input("Enter Book ID to issue: "))
user_id = int(input("Enter User ID to issue to: "))
issue_book(conn, book_id, user_id)

elif choice == '10':


book_id = int(input("Enter Book ID to return: "))
user_id = int(input("Enter User ID returning the book: "))
return_book(conn, book_id, user_id)

elif choice == '11':


display_books(conn)

P a g e | 17
elif choice == '12':
field = input("Enter field to search by (title/author/genre): ")
value = input(f"Enter {field} value to search for: ")
search_books(conn, **{field: value})

elif choice == '13':


print("Logging out from Admin Menu.")
break

else:
print("Invalid choice, please try again.")

def user_menu(conn, user_id):


"""User menu with options for viewing and searching books."""
while True:
print("\nUser Menu:")
print("1. Display All Books")
print("2. Search Books")
print("3. View Issued Book Details")
print("4. Log Out")

choice = input("Enter your choice: ")

if choice == '1':
display_books(conn)

elif choice == '2':


field = input("Enter field to search by (title/author/genre): ")
value = input(f"Enter {field} value to search for: ")
search_books(conn, **{field: value})

elif choice == '3':


issued_books_details(conn, user_id)

elif choice == '4':


print("Logging out from User Menu.")
break

else:
print("Invalid choice, please try again.")

def main():
# Step 1: Initialize the database and tables if they don't exist
initialize_database()

# Step 2: Connect to the database


conn = connect()
if not conn:
return

print("\nWelcome to the Library Management System")

# Step 3: Login
while True:
print("\n1. Log In")
print("2. Exit")
choice = input("Enter your choice: ")

if choice == '1':
username = input("Enter username: ")
password = input("Enter password: ")
user = authenticate(username, password)

if user:
if user['role'] == 'admin':
admin_menu(conn)
elif user['role'] == 'user':
user_menu(conn, user['user_id'])

P a g e | 18
else:
print("Login failed. Please try again.")

elif choice == '2':


print("Exiting the Library Management System.")
conn.close()
break

else:
print("Invalid choice, please try again.")

if __name__ == "__main__":
main()

P a g e | 19
OUTPUT

Python Interface
Database and tables are ready.
RUN Connected to LibraryDB.
TIME Welcome to the Library Management System

1. Log In
2. Exit
Enter your choice: 1
Enter username: admin
Enter password: 12345
Connected to LibraryDB.
Welcome, admin (admin)!

Admin Menu:
1. Add User
2. Delete User
3. Update User
4. Display Users
5. Search Users
6. Add Book
7. Delete Book
8. Update Book
9. Issue Book
10. Return Book
11. Display All Books
12. Search Books
13. Log Out
Enter your choice: 4
Users:
user_id username role
1 admin admin
2 john user
4 jane user

Admin Menu:
1. Add User
2. Delete User
3. Update User
4. Display Users
5. Search Users
6. Add Book
7. Delete Book
8. Update Book
9. Issue Book
10. Return Book
11. Display All Books
12. Search Books
13. Log Out
Enter your choice: 11
Available Books:
book_id title author genre publish_year isbn status
1 SAMPLE BOOK CS LAB FICTION 2024 11223344 available
2 SAMPLE BOOK 1 PHYSICS SCIENCE 2021 220033 available

Admin Menu:
1. Add User
2. Delete User
3. Update User
4. Display Users
5. Search Users
6. Add Book
7. Delete Book
8. Update Book
9. Issue Book
10. Return Book
11. Display All Books
12. Search Books
13. Log Out
Enter your choice: 9
Enter Book ID to issue: 1
Enter User ID to issue to: 2
Book ID 1 issued to User ID 2.

P a g e | 20
Admin Menu:
1. Add User
2. Delete User
3. Update User
4. Display Users
5. Search Users
6. Add Book
7. Delete Book
8. Update Book
9. Issue Book
10. Return Book
11. Display All Books
12. Search Books
13. Log Out
Enter your choice: 11
Available Books:
book_id title author genre publish_year isbn status
2 SAMPLE BOOK 1 PHYSICS SCIENCE 2021 220033 available

Admin Menu:
1. Add User
2. Delete User
3. Update User
4. Display Users
5. Search Users
6. Add Book
7. Delete Book
8. Update Book
9. Issue Book
10. Return Book
11. Display All Books
12. Search Books
13. Log Out
Enter your choice: 12
Enter field to search by (title/author/genre): title
Enter title value to search for: sample
Search Results:
book_id title author genre publish_year isbn status
2 SAMPLE BOOK 1 PHYSICS SCIENCE 2021 220033 available

Admin Menu:
1. Add User
2. Delete User
3. Update User
4. Display Users
5. Search Users
6. Add Book
7. Delete Book
8. Update Book
9. Issue Book
10. Return Book
11. Display All Books
12. Search Books
13. Log Out
Enter your choice: 8
Enter Book ID to update: 2
New title (leave blank to skip): SAMPLE BOOK 2024 1
New author (leave blank to skip):
New genre (leave blank to skip):
New publish year (leave blank to skip):
New ISBN (leave blank to skip):
Book ID 2 updated successfully.

Admin Menu:
1. Add User
2. Delete User
3. Update User
4. Display Users
5. Search Users
6. Add Book
7. Delete Book
8. Update Book
9. Issue Book
10. Return Book
11. Display All Books
12. Search Books
13. Log Out
Enter your choice: 11
Available Books:

P a g e | 21
book_id title author genre publish_year isbn status
2 SAMPLE BOOK 2024 1 PHYSICS SCIENCE 2021 220033 available

Admin Menu:
1. Add User
2. Delete User
3. Update User
4. Display Users
5. Search Users
6. Add Book
7. Delete Book
8. Update Book
9. Issue Book
10. Return Book
11. Display All Books
12. Search Books
13. Log Out
Enter your choice: 13
Logging out from Admin Menu.

1. Log In
2. Exit
Enter your choice: 1
Enter username: john
Enter password: 123
Connected to LibraryDB.
Welcome, john (user)!

User Menu:
1. Display All Books
2. Search Books
3. View Issued Book Details
4. Log Out
Enter your choice: 3
Issued Book Details:
book_id title author issue_date return_date
1 SAMPLE BOOK CS LAB 2024-11-14 09:48:00 None
2 SAMPLE BOOK 2024 1 PHYSICS 2024-11-14 09:44:20 2024-11-14

User Menu:
1. Display All Books
2. Search Books
3. View Issued Book Details
4. Log Out
Enter your choice: 1
Available Books:
book_id title author genre publish_year isbn status
2 SAMPLE BOOK 2024 1 PHYSICS SCIENCE 2021 220033 available

User Menu:
1. Display All Books
2. Search Books
3. View Issued Book Details
4. Log Out
Enter your choice: 4
Logging out from User Menu.

1. Log In
2. Exit
Enter your choice: 1
Enter username: admin
Enter password: 12345
Connected to LibraryDB.
Welcome, admin (admin)!

Admin Menu:
1. Add User
2. Delete User
3. Update User
4. Display Users
5. Search Users
6. Add Book
7. Delete Book
8. Update Book
9. Issue Book
10. Return Book
11. Display All Books
12. Search Books
13. Log Out
Enter your choice: 10

P a g e | 22
Enter Book ID to return: 1
Enter User ID returning the book: 2
Book ID 1 returned by User ID 2.

Admin Menu:
1. Add User
2. Delete User
3. Update User
4. Display Users
5. Search Users
6. Add Book
7. Delete Book
8. Update Book
9. Issue Book
10. Return Book
11. Display All Books
12. Search Books
13. Log Out
Enter your choice: 11
Available Books:
book_id title author genre publish_year isbn status
1 SAMPLE BOOK CS LAB FICTION 2024 11223344 available
2 SAMPLE BOOK 2024 1 PHYSICS SCIENCE 2021 220033 available

Admin Menu:
1. Add User
2. Delete User
3. Update User
4. Display Users
5. Search Users
6. Add Book
7. Delete Book
8. Update Book
9. Issue Book
10. Return Book
11. Display All Books
12. Search Books
13. Log Out
Enter your choice: 13
Logging out from Admin Menu.

1. Log In
2. Exit
Enter your choice: 1
Enter username: john
Enter password: 123
Connected to LibraryDB.
Welcome, john (user)!

User Menu:
1. Display All Books
2. Search Books
3. View Issued Book Details
4. Log Out
Enter your choice: 3
Issued Book Details:
book_id title author issue_date return_date
1 SAMPLE BOOK CS LAB 2024-11-14 09:48:00 2024-11-14
2 SAMPLE BOOK 2024 1 PHYSICS 2024-11-14 09:44:20 2024-11-14

User Menu:
1. Display All Books
2. Search Books
3. View Issued Book Details
4. Log Out
Enter your choice: 4
Logging out from User Menu.

1. Log In
2. Exit
Enter your choice: 2
Exiting the Library Management System.

P a g e | 23
Database
1.

Figure 1 Tables present in the database 'LibraryDB'

2.

Figure 2 Schema of the table Books

3.

Figure 3 Schema of the table Users

P a g e | 24
4.

Figure 4 Schema of the table IssuedBooks

5.

Figure 5 Displaying all the tuples in the table Users

6.

Figure 6 Displaying all the books

P a g e | 25
BIBLIOGRAPHY

Sl. Description Link


1. Python https://python.org
2. MySQL https://mysql.org
3. Python Pandas https://pandas.pydata.org/
4. PyPI • mysql-connector-python https://pypi.org/project/mysql-
connector-python/
5. Computer Science with Python Textbook for
Class 11 - by Sumita Arora
6. Computer Science with Python Textbook for
Class 12 - by Sumita Arora
7. Class 11th & 12th Computer Science Arihant
Books

P a g e | 26

You might also like