A simple Library Management System built with Python and MySQL that allows you to:
- INSERT new books into the catalog
- UPDATE existing book records
- DELETE books from the catalog
- DISPLAY all books in the catalog
- SEARCH for books by title, author, or ISBN
- INSERT
- Add new books with details: Title, Author, ISBN, Publisher, Year, Quantity.
- UPDATE
- Modify any field of an existing book record.
- DELETE
- Remove books by their unique ID or ISBN.
- DISPLAY
- List all books in a clean tabular format.
- SEARCH
- Find books by Title, Author, or ISBN (supports partial matches).
- Python 3.7+
- MySQL Server 5.7+
mysql-connector-python(orPyMySQL)
-
Clone the repository
git clone https://github.com/AitijhyaCoded/Library-Management-System.git cd Library-Management-System -
Create & activate a virtual environment (optional but recommended)
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Python dependencies
pip install -r requirements.txt
-
Start MySQL and log in as root (or a user with CREATE privileges):
mysql -u root -p
-
Create a new database:
CREATE DATABASE library_db; USE library_db;
-
Create the
bookstable (run the SQL inschema.sql):-- schema.sql CREATE TABLE books ( id INT AUTO_INCREMENT PRIMARY KEY, title VARCHAR(255) NOT NULL, author VARCHAR(255) NOT NULL, isbn VARCHAR(20) UNIQUE NOT NULL, publisher VARCHAR(255), year YEAR, quantity INT DEFAULT 1 );
- Copy the sample config and update with your MySQL credentials:
cp config_example.py config.py
- Edit
config.py:DB_CONFIG = { 'host': 'localhost', 'user': 'your_mysql_username', 'password': 'your_mysql_password', 'database': 'library_db' }
Run the main script to launch the interactive menu:
python pro12bSECRET.pyYou will see options:
1. Insert
2. Update
3. Delete
4. Display
5. Search
6. Exit
- Insert: Enter book details when prompted.
- Update: Provide the Book ID or ISBN, then choose which field(s) to update.
- Delete: Provide the Book ID or ISBN to remove the record.
- Display: Shows all books in a formatted table.
- Search: Enter a keyword to search by Title, Author, or ISBN.