The Library Management System (LMS) is a console-based application built using Python and Object-Oriented Programming (OOP) principles. It manages books, members, and the transactions involved in lending and returning books. Data persistence is achieved by integrating the application with a MySQL relational database.
The system implements a full set of CRUD (Create, Read, Update, Delete) operations and transaction logic:
- Add a New Book: Register a new title with details (Title, Author, ISBN, Quantity).
- Delete a Book: Remove a book record by its ID.
- Update Book Details: Modify the available quantity of a book.
- View Book Details: Retrieve details for a single book or list all books in a structured format.
- Register a New Member: Add new members with their name, phone, and email.
- View All Members: List all registered library members.
- Issue a Book: Decrements book quantity, logs a transaction record with an issue date, and prevents double-issuance of the same book to the same member.
- Return a Book: Increments book quantity, and updates the transaction record with a return date.
| Component | Technology | Role |
|---|---|---|
| Language | Python 3.x | Core application logic (OOP) |
| Database | MySQL | Secure and persistent data storage |
| Connector | mysql-connector-python |
Python-to-MySQL communication |
| Structure | Modular OOP | Separation of Concerns (Data Models, Business Logic) |
📁Library_Management_System # Root Folder
├── 📁core # Python Package containing all core logic
├── __init__.py # Exposes core classes (Book, Member, Library and more)
├── book.py # Book Class (Data Model )
├── db_connector.py # Database Connector Class
├── query_helper.py # Query Helper Class (Utility Methods)
├── member.py # Member Class (Data Model)
└── library.py # Library Class (Business Logic & DB Connector)
├── 📁schema # SQL scripts for database setup
└── library_schema.sql # SQL script for database/table creation
├── .env.example # Example environment variables file
├── .gitignore # Git ignore file
├── app.py # Main execution script (User Interface/Menu)
├── requirements.txt # List of Python dependencies
└── README.md # Project documentation and setup instructionsFollow these steps to get the project running on your local machine.
- Python 3.x: Ensure Python is installed.
- MySQL Server: Ensure a local MySQL server instance is running (e.g., via XAMPP, Docker, or standalone installation).
git clone https://github.com/YourUsername/Library_Management_System.git
cd Library_Management_SystemYou only need the MySQL connector library.
pip install mysql-connector-pythonYou must set up the database and tables before running the script.
-
Create Database Schema: Execute the SQL commands in
docs/library_schema.sqlon your MySQL server. This creates thelibrary_dbdatabase and thebooks,members, andtransactionstables.-- Example of the necessary tables: CREATE TABLE books (...); CREATE TABLE members (...); CREATE TABLE transactions (...);
-
Update Credentials: Open the
main.pyfile and update the database connection variables (DB_HOST,DB_USER,DB_PASSWORD,DB_NAME) to match your local MySQL configuration.# In main.py DB_HOST = "localhost" DB_USER = "root" DB_PASSWORD = "your_mysql_password" # <-- CHANGE THIS DB_NAME = "library_db"
Execute the main script from the root directory:
python main.pyThe console menu will appear, allowing you to interact with the system.
The project rigorously follows OOP principles:
- Encapsulation: Attributes in the
BookandMemberclasses are marked as private (using__prefix) and accessed via public getter@propertymethods. - Separation of Concerns:
- Data Models (
book.py,member.py) handle object data structure only. - Business Logic (
library.py) handles all database connections, validation, and core transaction logic. - User Interface (
main.py) handles only user interaction and input validation.
- Data Models (
This structure allows for easy maintenance and future expansion (e.g., adding a GUI or a web interface).
- Late Fee Calculation: Implement logic within
return_bookto calculate fees based on issue and return dates. - Search Functionality: Add robust search options (by title, author, or member name).
- Data Export: Implement options to export book or member lists to CSV or Excel.
- Implement add book functionality.
- Implement view book details functionality.
- Implement member registration functionality.
- Implement issue book functionality.
- Implement return book functionality.
- Implement view member transactions functionality.
- Add error handling for database operations.
- Add search functionality for books and members.
- Write unit tests for core classes and methods.
- Create a GUI or web interface for better user experience.
- Implement late fee calculation logic.
- Calculate late fees based on issue and return dates.
- Integrate fee calculation into the return_book method.
- Add user prompts for fee payment during book return.
- Update database schema to store late fee information.
- Consider edge cases (e.g., lost books, damaged books).
- Provide admin options to waive or adjust late fees.
- Ensure compliance with local regulations regarding late fees.
- Test late fee functionality thoroughly.