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

Ip Project

Uploaded by

jeansmom944
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)
33 views28 pages

Ip Project

Uploaded by

jeansmom944
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

RISHIKUL WORLD ACADEMY SONEPAT

Affiliated to Central Board Of Secondary Education

INFORMATICS PRACTICES (065)


PROJECT FILE

SUBMITTED BY:
SUBMITTED TO: Prikshit Ghangas
Ms. Ashu Bhardwaj

ROLL NO:

CLASS: XII-NM
ACKNOWLEDGEMENt
I would like to express my sincere gratitude to all those
who have helped me in completing this (IP) Project. First
and foremost, I would like to thank my teacher, Ms Ashu
Bhardwaj whose guidance, expertise, and constant
encouragement made this project assignment both
interesting and educational.
I would also like to extend my thanks to my classmates and
peers for their collaborative support and assistance during
the project exercises. Their insights and discussions greatly
enriched my understanding of the subject.
Finally, I would like to thank Rishikul World Academy for
providing the resources and infrastructure necessary to
conduct this project and gain valuable hands-on experience
with Information Practices concepts.
CErtifiCAtE
This is to certify that Prikshit Ghangas has successfully
completed the project assignment for the Information
Practices (IP) course at Rishikul World Academy. The
project was conducted under the guidance of Ms. Ashu
Bhardwaj whose invaluable expertise and encouragement
made this assignment an enriching learning experience.
The project involved the exploration and application of key
concepts in Information Practices, and through this
hands-on experience, the student demonstrated an
understanding of the subject matter.
We appreciate the collaborative efforts of the student's
classmates and peers, whose support contributed to the
success of this project.

External Examiner Subject Teacher


Principal
iNDEX
S.No. TITLE PAGE NO
01 Introduction

02 Objective

03 System Requirements

04 Source Code

05 Output

06 Conclusion

07 Reference
iNtrODUCtiON
Introduction
The Library Management System is a console-based
application built using Python and SQLite, designed to help
manage books, users, and transactions in a library. This
system allows users to:
 View all available books
 Search for books by title or author
 Borrow and return books
 Add or remove books
 Add new users
 View transaction history
The system maintains the following data:
 Books: Information about books in the library,
including title, author, and availability status.
 Users: Information about the library's users.
 Transactions: Records of books borrowed and
returned by users.
Features
1. View Books
This function allows the user to view all books available in
the library. It displays the following information in a table-
like format:
 ID: Unique identifier for each book.
 Title: Title of the book.
 Author: Author of the book.
 Available: Availability status of the book (Yes/No).
2. Search for a Book
The user can search for a book by title or author. The
system will display the matching books in a table-like
format. If no books are found, a message indicating "No
books found with the given search term" is displayed.
3. Borrow a Book
The user can borrow a book by providing their name and
the book's ID. The system will check if the book is
available, and if so, it will record the borrowing transaction
and mark the book as unavailable. The borrow date is also
stored in the system.
4. Return a Book
Users can return a borrowed book by providing their name
and the book's ID. If the user has an active borrowing
transaction, the return date is recorded, and the book is
marked as available again.
5. Add or Remove a Book
This function allows the user to either add a new book or
remove an existing one:
 Add a Book: The user can provide the title and author
of the book, and the system will add it to the library.
 Remove a Book: The user can provide the book's ID to
remove it from the library. If the book is currently
borrowed, it will be removed from the system, but the
transaction history will remain intact.
6. Add a New User
The system allows the addition of new users by entering
their name. This feature helps in maintaining user records
for transactions.
7. Transaction History
Users can view their transaction history, including the
books they borrowed and returned. The history displays the
book's title, borrow date, and return date (if applicable).
OBJECtiVE
The primary objective of this project is to develop an Air
Ticket Booking System that offers a user-friendly
interface for managing flight bookings. The system will
allow users to:
 View available flights
 Book tickets
 Track their booking history
 Manage flight details (Admin features)
By integrating Python with SQLite, the system will
demonstrate the practical use of databases in real-world
applications, providing an efficient solution for managing
flight bookings.
SyStEM rEQUirEMENtS
System Requirements for Air Ticket Booking System
1. Hardware Requirements
 Processor: Intel i3 or higher (or equivalent)
 RAM: Minimum 4GB (8GB recommended for smooth
processing)
 Storage: At least 500MB of free space for Python
installation, libraries, and temporary data storage
 Operating System: Windows, macOS, or Linux (the
system is platform-independent, as long as Python and
SQLite are supported)
2. Software Requirements
 Programming Language: Python 3.6 or higher
 Libraries and Dependencies:
o SQLite: For the database to store flight and
booking information
o datetime: For managing booking timestamps and
time-based operations
o os: For managing file paths (used in file operations
like database file handling)
SOUrCE CODE
import sqlite3
from datetime import datetime

# Initialize the database


def initialize_database():
conn = sqlite3.connect('library.db')
cursor = conn.cursor()

# Create tables
cursor.execute('''CREATE TABLE IF NOT EXISTS
books (
book_id INTEGER
PRIMARY KEY,
title TEXT,
author TEXT,
available INTEGER)''')

cursor.execute('''CREATE TABLE IF NOT EXISTS


transactions (
transaction_id INTEGER
PRIMARY KEY,
book_id INTEGER,
user_name TEXT,
borrow_date TEXT,
return_date TEXT,
FOREIGN KEY (book_id)
REFERENCES books(book_id))''')

cursor.execute('''CREATE TABLE IF NOT EXISTS


users (
user_id INTEGER
PRIMARY KEY,
user_name TEXT)''')

# Add sample book data


cursor.executemany('''INSERT OR IGNORE INTO
books (book_id, title, author, available)
VALUES (?, ?, ?, ?)''', [
(1, "To Kill a
Mockingbird", "Harper Lee", 1),
(2, "1984", "George
Orwell", 1),
(3, "The Great Gatsby",
"F. Scott Fitzgerald", 1)])

# Add sample user data


cursor.executemany('''INSERT OR IGNORE INTO
users (user_id, user_name)
VALUES (?, ?)''', [
(1, "John Doe"),
(2, "Jane Smith")])

conn.commit()
conn.close()

# Function to view books in a table-like format


def view_books():
conn = sqlite3.connect('library.db')
cursor = conn.cursor()
cursor.execute("SELECT * FROM books")
books = cursor.fetchall()
print("\nBooks in the Library:")
print(f"{'ID':<5} {'Title':<50} {'Author':<25}
{'Available':<10}")
print("-" * 90) # Adjusted width for larger title
for book in books:
status = "Yes" if book[3] else "No"
print(f"{book[0]:<5} | {book[1]:<50} |
{book[2]:<25} | {status:<10}")

conn.close()

# Function to search for a book by title or author


def search_books():
search_term = input("Enter the title or author to search:
")

conn = sqlite3.connect('library.db')
cursor = conn.cursor()
cursor.execute("SELECT * FROM books WHERE
title LIKE ? OR author LIKE ?", ('%' + search_term + '%',
'%' + search_term + '%'))
books = cursor.fetchall()

if not books:
print("\nNo books found with the given search
term.")
else:
print("\nSearch Results:")
print(f"{'ID':<5} {'Title':<50} {'Author':<25}
{'Available':<10}")
print("-" * 90) # Adjusted width for larger title
for book in books:
status = "Yes" if book[3] else "No"
print(f"{book[0]:<5} | {book[1]:<50} |
{book[2]:<25} | {status:<10}")

conn.close()

# Function to borrow a book


def borrow_book():
user_name = input("Enter your name: ")
book_id = int(input("Enter the Book ID you want to
borrow: "))
conn = sqlite3.connect('library.db')
cursor = conn.cursor()

cursor.execute("SELECT available FROM books


WHERE book_id = ?", (book_id,))
book = cursor.fetchone()

if book and book[0] == 1: # Check if the book is


available
borrow_date = datetime.now().strftime("%Y-
%m-%d %H:%M:%S")
cursor.execute("INSERT INTO transactions
(book_id, user_name, borrow_date) VALUES (?, ?, ?)",
(book_id, user_name,
borrow_date))
cursor.execute("UPDATE books SET available =
0 WHERE book_id = ?", (book_id,))
conn.commit()
print(f"Book borrowed successfully by
{user_name}!")
else:
print("Book is not available or doesn't exist.")

conn.close()

# Function to return a book


def return_book():
user_name = input("Enter your name: ")
book_id = int(input("Enter the Book ID you want to
return: "))

conn = sqlite3.connect('library.db')
cursor = conn.cursor()

cursor.execute("SELECT * FROM transactions


WHERE book_id = ? AND user_name = ? AND
return_date IS NULL", (book_id, user_name))
transaction = cursor.fetchone()

if transaction:
return_date = datetime.now().strftime("%Y-%m-
%d %H:%M:%S")
cursor.execute("UPDATE transactions SET
return_date = ? WHERE transaction_id = ?", (return_date,
transaction[0]))
cursor.execute("UPDATE books SET available =
1 WHERE book_id = ?", (book_id,))
conn.commit()
print(f"Book returned successfully by
{user_name}!")
else:
print("No active borrowing transaction found for
this book.")

conn.close()

# Combined function to add or remove a book


def add_remove_book():
action = input("Would you like to (A)dd or (R)emove
a book? (Enter A or R): ").upper()

if action == 'A':
title = input("Enter the book title: ")
author = input("Enter the author's name: ")
conn = sqlite3.connect('library.db')
cursor = conn.cursor()

cursor.execute("INSERT INTO books (title,


author, available) VALUES (?, ?, ?)", (title, author, 1))
conn.commit()
print(f"Book '{title}' by {author} added
successfully.")

conn.close()

elif action == 'R':


book_id = int(input("Enter the Book ID you want
to remove: "))

conn = sqlite3.connect('library.db')
cursor = conn.cursor()

cursor.execute("DELETE FROM books WHERE


book_id = ?", (book_id,))
conn.commit()
print(f"Book with ID {book_id} removed from
the library.")

conn.close()

else:
print("Invalid choice! Please enter 'A' to add or
'R' to remove a book.")

# Function to add a new user


def add_user():
user_name = input("Enter the new user's name: ")

conn = sqlite3.connect('library.db')
cursor = conn.cursor()

cursor.execute("INSERT INTO users (user_name)


VALUES (?)", (user_name,))
conn.commit()
print(f"User {user_name} added successfully.")
conn.close()
# Function to generate transaction history for a user
def transaction_history():
user_name = input("Enter your name to view
transaction history: ")

conn = sqlite3.connect('library.db')
cursor = conn.cursor()

cursor.execute("SELECT books.title,
transactions.borrow_date, transactions.return_date "
"FROM transactions JOIN books
ON books.book_id = transactions.book_id "
"WHERE transactions.user_name
= ?", (user_name,))
transactions = cursor.fetchall()

print(f"\nTransaction History for {user_name}:")


print(f"{'Title':<50} {'Borrow Date':<20} {'Return
Date':<20}")
print("-" * 90)
for transaction in transactions:
print(f"{transaction[0]:<50} {transaction[1]:<20}
{transaction[2] if transaction[2] else 'Not Returned':<20}")

conn.close()

# Main menu function


def main_menu():
initialize_database()
while True:
print("\n--- Library Management System ---")
print("1. View Books")
print("2. Search for a Book")
print("3. Borrow a Book")
print("4. Return a Book")
print("5. Add/Remove a Book")
print("6. Add a New User")
print("7. Transaction History")
print("8. Exit")

choice = input("Enter your choice: ")


if choice == "1":
view_books()
elif choice == "2":
search_books()
elif choice == "3":
borrow_book()
elif choice == "4":
return_book()
elif choice == "5":
add_remove_book()
elif choice == "6":
add_user()
elif choice == "7":
transaction_history()
elif choice == "8":
print("Exiting the system. Thank you!")
break
else:
print("Invalid choice! Please enter a number
between 1 and 8.")
# Run the program
main_menu()
OUtPUt
Main Menu :-
--- Air Ticket Booking System ---
1. View Flights
2. Book a Ticket
3. View Bookings
4. Exit
Enter your choice: 1

Viewing Flights :-
Available Flights:
Flight ID | Airline | From | To | Departure
| Arrival | Price
1 | Air India | Delhi | Mumbai | 10:00
| 12:00 | 5000.0
2 | IndiGo | Mumbai | Chennai | 14:00
| 16:30 | 4000.0
3 | SpiceJet | Bangalore| Kolkata | 18:00
| 21:00 | 4500.0

Booking a Ticket :-
Enter your name: John Doe
Available Flights:
Flight ID | Airline | From | To | Departure
| Arrival | Price
1 | Air India | Delhi | Mumbai | 10:00
| 12:00 | 5000.0
2 | IndiGo | Mumbai | Chennai | 14:00
| 16:30 | 4000.0
3 | SpiceJet | Bangalore| Kolkata | 18:00
| 21:00 | 4500.0
Enter the Flight ID you want to book: 2
Booking successful!

Viewing Bookings :-
Your Bookings:
Booking ID | Name | Flight ID | Date
1 | John Doe |2 | 2024-12-18
14:30:00

Exit :-
Exiting the system. Thank you!
CONCLUSiON
The Library Management System project effectively
demonstrates the integration of Python programming and
SQL database management to create a comprehensive
solution for managing library operations. By offering
features like adding and removing books, borrowing and
returning books, and viewing book transactions, this project
provides valuable hands-on experience with database
management, Python programming, and real-world
software development concepts.
This project serves as an excellent learning tool for
understanding how technology can simplify and streamline
library management processes. It showcases how to handle
structured data, manage user interactions, and automate
tasks like cataloging books and tracking transactions.
Furthermore, it highlights the importance of creating
efficient and user-friendly systems for everyday operations
in institutions like libraries.
In addition to its educational value, the Library
Management System serves as a foundational framework
for more advanced features that could be added in the
future, such as integrating user authentication, generating
reports, or creating a web-based interface. The project
demonstrates the potential of Python and SQL in creating
scalable and adaptable solutions that can be applied to real-
world problems in educational and organizational settings.
Overall, this project exemplifies how a well-designed
software system can optimize daily tasks, making it an
essential tool for managing library resources and improving
user experience.
rEfErENCES
The data used in the Library Management System project
is fictional and created for educational purposes. Below is a
breakdown of the data sources and inspirations used in the
development of the system:
Book Information
1. Book titles, authors, genres, and publication dates
were designed as sample data to demonstrate the
functionality of the system.
2. These details do not correspond to real books or
authors but are intended to simulate a typical
library database.
Database Design
1. The database schema (tables for books, users, and
transactions) was structured based on common
practices in library management systems, inspired
by resources from platforms such as W3Schools,
Real Python, and various SQL tutorials.
2. The relational design ensures that data integrity and
efficiency are maintained while enabling flexible
queries for managing book transactions.
Transaction Details
1. User-provided inputs, such as book
borrowing/returning and user information, are
collected during runtime and stored dynamically in
the SQLite database.
2. The project’s workflow mimics real-world library
operations like checking out books and tracking
their return dates.
The purpose of this project is to demonstrate the integration
of Python and SQL in creating a functional library
management system. All data used in this system is
fictional and intended for simulation and educational
purposes only. For real-world use, the dataset can be
customized to include actual library books and user
information.
If you need help integrating real-world data or modifying
the system to suit specific requirements, feel free to reach
out!

You might also like