Library Management System Project 1

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

Library Management

System Project
Creating a Library Management System (LMS) as a project for your Class 12
Computer Science is a great idea! Here’s a step-by-step guide to help you
structure and develop your project.
Project Planning

1 Define Objectives 2 System Design


Efficiently manage book information, track Features: Add, update, delete books, register
borrowed and returned books, maintain user new users (students/teachers), issue and
(student/teacher) records, and generate return books, search for books, generate
reports (overdue books, book availability, reports, and user authentication.
etc.).
Technology Stack
Programming Language Database User Interface
Python is a great choice for this SQLite is a lightweight and easy- Tkinter is a good option for
project due to its simplicity and to-use database that integrates creating desktop GUI
extensive libraries. well with Python. applications, while Flask is
suitable for web applications.
Database Schema
Table Columns

books book_id, title, author, publisher, year, copies

users user_id, name, role, contact

transactions transaction_id, user_id, book_id, issue_date,


return_date, status
User Interface Design
Add Books Issue Books
Design a user-friendly interface for adding Create a section for issuing books to users,
new books to the system. including user authentication and book
availability checks.

Return Books
Implement a feature for returning books, updating transaction records, and calculating
overdue fees.
Implementation
Here's a simplified version of what your Python code could look like using Tkinter for the GUI and SQLite for
the database.

import sqlite3

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

# Create books table


cursor.execute('''CREATE TABLE IF NOT EXISTS books (
book_id INTEGER PRIMARY KEY,
title TEXT,
author TEXT,
publisher TEXT,
year INTEGER,
copies INTEGER
)''')
# Create users table
cursor.execute('''CREATE TABLE IF NOT EXISTS users (
user_id INTEGER PRIMARY KEY,
name TEXT,
role TEXT,
contact TEXT
)''')
# Create transactions table
cursor.execute('''CREATE TABLE IF NOT EXISTS transactions (
transaction_id INTEGER PRIMARY KEY,
user_id INTEGER,
book_id INTEGER,
issue_date TEXT,
return_date TEXT,
status TEXT,
FOREIGN KEY(user_id) REFERENCES users(user_id),
FOREIGN KEY(book_id) REFERENCES books(book_id)
)''')
conn.commit()
conn.close()

setup_database()

import tkinter as tk
from tkinter import messagebox
import sqlite3
from datetime import datetime

# Function to add a new book

def add_book():
conn = sqlite3.connect('library.db')
cursor = conn.cursor()
cursor.execute("INSERT INTO books (title, author, publisher, year, copies) VALUES (?, ?, ?, ?, ?)",
(title_entry.get(), author_entry.get(), publisher_entry.get(), year_entry.get(), copies_entry.get()))
conn.commit()
conn.close()
messagebox.showinfo("Success", "Book added successfully")

# Function to issue a book

def issue_book():
conn = sqlite3.connect('library.db')
cursor = conn.cursor()
cursor.execute("INSERT INTO transactions (user_id, book_id, issue_date, status) VALUES (?, ?, ?,
?)", (user_id_entry.get(), book_id_entry.get(), datetime.now().strftime("%Y-%m-%d"), "Issued"))
cursor.execute("UPDATE books SET copies = copies - 1 WHERE book_id = ?",
(book_id_entry.get(),))
conn.commit()
conn.close()
messagebox.showinfo("Success", "Book issued successfully")

# Function to return a book

def return_book():
conn = sqlite3.connect('library.db')
cursor = conn.cursor()
cursor.execute("UPDATE transactions SET return_date = ?, status = ? WHERE transaction_id = ?",
(datetime.now().strftime("%Y-%m-%d"), "Returned", transaction_id_entry.get()))
cursor.execute("UPDATE books SET copies = copies + 1 WHERE book_id = ?",
(book_id_entry.get(),))
conn.commit()
conn.close()
messagebox.showinfo("Success", "Book returned successfully")

# Tkinter UI setup

root = tk.Tk()
root.title("Library Management System")

# Add Book

tk.Label(root, text="Title").grid(row=0, column=0)


title_entry = tk.Entry(root)
title_entry.grid(row=0, column=1)

tk.Label(root, text="Author").grid(row=1, column=0)


author_entry = tk.Entry(root)
author_entry.grid(row=1, column=1)

tk.Label(root, text="Publisher").grid(row=2, column=0)


publisher_entry = tk.Entry(root)
publisher_entry.grid(row=2, column=1)

tk.Label(root, text="Year").grid(row=3, column=0)


year_entry = tk.Entry(root)
year_entry.grid(row=3, column=1)

tk.Label(root, text="Copies").grid(row=4, column=0)


copies_entry = tk.Entry(root)
copies_entry.grid(row=4, column=1)

tk.Button(root, text="Add Book", command=add_book).grid(row=5, columnspan=2)

# Issue Book

tk.Label(root, text="User ID").grid(row=6, column=0)


user_id_entry = tk.Entry(root)
user_id_entry.grid(row=6, column=1)

tk.Label(root, text="Book ID").grid(row=7, column=0)


book_id_entry = tk.Entry(root)
book_id_entry.grid(row=7, column=1)

tk.Button(root, text="Issue Book", command=issue_book).grid(row=8, columnspan=2)

# Return Book

tk.Label(root, text="Transaction ID").grid(row=9, column=0)


transaction_id_entry = tk.Entry(root)
transaction_id_entry.grid(row=9, column=1)

tk.Button(root, text="Return Book", command=return_book).grid(row=10, columnspan=2)

root.mainloop()
Testing
1 Unit Testing
Test each function individually to ensure it works as expected.

2 Integration Testing
Test how different parts of the system interact with each other.

3 System Testing
Test the entire system to ensure it meets all requirements.
Documentation and Presentation

Code Documentation User Manual Presentation


Write clear and concise Create a user manual that guides Prepare a presentation explaining
comments explaining the purpose users on how to use the system, the objectives, design,
of each function and code block. including screenshots and implementation, and
examples. functionalities of your Library
Management System.

You might also like