Csproject
Csproject
Csproject
2
Satna,(M.P.)
Session:-2023-24
Thank You!!
Introduction:
The Library Management System (LMS) is an
automated solution designed to streamline the
management of books and resources in a library.
Project Objectives:
- Automate book management processes.
- Provide secure user authentication.
- Integrate with a database for data storage.
- Create a user-friendly GUI for interaction.
System Requirements:
- Python 3.x
- Tkinter (for GUI)
- SQLite (for database)
Features:
- User Authentication
- Book Management (Add, Borrow, Return)
- Database Integration
- Graphical User Interface (GUI)
- Error Handling
System Architecture:
- User interacts with the GUI.
- GUI communicates with the Library and
UserAuthentication classes.
- The Library class interacts with the SQLite
database.
User Roles:
- Admin (Librarian)
- Can access all features.
- Library User
- Can borrow and return books.
Implementation Details:
a. User Authentication:
- SQLite database stores hashed user
credentials.
- Bcrypt used for password hashing.
- Credentials validated during login.
b.Database Integration:
- SQLite database for storing book details.
- SQL queries used for CRUD operations.
c. Library Class:
- Book and Library classes handle book-related
operations.
- Methods include add_book, display_books,
borrow_book, and return_book.
d. GUI Design:
- Tkinter used for GUI development.
- Login screen with username and password
fields.
- Main interface with a listbox and buttons.
e. Error Handling:
- User-friendly error messages for invalid
actions.
- Exception handling for unexpected issues.
class Book:
def __init__(self, title, author, ISBN, copies):
self.title = title
self.author = author
self.ISBN = ISBN
self.copies = copies
self.available_copies = copies
class Library:
def __init__(self):
self.books = []
def add_book(self, book):
self.books.append(book)
def display_books(self):
return self.books
class UserAuthentication:
def __init__(self, db_path='library.db'):
self.conn = sqlite3.connect(db_path)
self.cursor = self.conn.cursor()
self.create_user_table()
def create_user_table(self):
self.cursor.execute('''CREATE TABLE IF NOT
EXISTS users (username TEXT, password TEXT)''')
self.conn.commit()
class LibraryApp:
def __init__(self, master, library, auth):
self.master = master
self.master.title("Library Management System")
self.password_label = Label(master,
text="Password:")
self.password_label.pack()
self.password_entry = Entry(master, show="*")
self.password_entry.pack()
self.books_listbox = Listbox(master)
self.books_listbox.pack()
self.borrow_button = Button(master,
text="Borrow Book", command=self.borrow_book)
self.borrow_button.pack()
self.return_button = Button(master,
text="Return Book", command=self.return_book)
self.return_button.pack()
self.library = library
self.auth = auth
self.init_books()
def init_books(self):
book1 = Book("Introduction to Python", "John
Smith", "123456789", 5)
book2 = Book("Data Structures in Python",
"Jane Doe", "987654321", 3)
self.library.add_book(book1)
self.library.add_book(book2)
self.update_books_listbox()
def update_books_listbox(self):
self.books_listbox.delete(0, "end")
for book in self.library.display_books():
self.books_listbox.insert("end", f"{book.title}
- {book.available_copies} available")
def login(self):
entered_username = self.username_entry.get()
entered_password = self.password_entry.get()
if self.auth.login(entered_username,
entered_password):
self.show_message("Login Successful")
self.show_books()
else:
self.show_message("Invalid Credentials")
def borrow_book(self):
selected_index =
self.books_listbox.curselection()
if selected_index:
selected_book =
self.library.display_books()[selected_index[0]]
result =
self.library.borrow_book(selected_book.title)
self.show_message(result)
self.update_books_listbox()
else:
self.show_message("Select a book to
borrow")
def return_book(self):
selected_index =
self.books_listbox.curselection()
if selected_index:
selected_book =
self.library.display_books()[selected_index[0]]
result =
self.library.return_book(selected_book.title)
self.show_message(result)
self.update_books_listbox()
else:
self.show_message("Select a book to return")
if __name__ == "__main__":
# Create SQLite database and table for users
(dummy data for illustration)
conn = sqlite3.connect('library.db')
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS
users (username TEXT, password TEXT)''')
c.execute("INSERT OR IGNORE INTO users
VALUES ('admin',
'$2b$12$Z8TWd.1myfmy.SqWUzqTpOmDrWVeqom
5LoI0ADMPuV19QhJlcs75y')")
conn.commit()
conn.close()
root = Tk()
auth = UserAuthentication()
library = Library()
app = LibraryApp(root, library, auth)
root.mainloop()
Conclusion:
- The LMS simplifies library operations, improving
efficiency and user experience.
- Challenges included securing user data and
ensuring smooth database interactions.
Future Enhancements:
- Implement multi-user support.
- Add search and sorting features for books.
- Explore the possibility of integrating with an
online book database.
BIBLIOGRAPHY :-
Sunita Arora – Comptuter Science with Python
Preeti Arora – Comptuter Science with Python
www.Github.com