A Library Management System built using Python and MySQL.
This project allows users to register, log in, borrow, and return books, and enables an admin to manage all library operations.
- Student Name: Saurav Sharma
- Student ID: 25MCD10017
- Course: MCA (Data Science)
- University: Chandigarh University
- Project Type: Mini Project
- Semester: [1st SEM]
- Register and log in securely (email validation included)
- View available books
- Borrow and return books
- View personal borrowed book history
- Admin login with special privileges
- View all borrowed books with user details
- Add, search, and delete books
- Manage all user activities
- Programming Language: Python
- Database: MySQL
- Libraries Used:
mysql.connectorre(for email validation)datetime
- Open MySQL Workbench or terminal.
- Create a new database:
CREATE DATABASE library_db; USE library_db; CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(100) UNIQUE NOT NULL, email VARCHAR(150) UNIQUE NOT NULL, password VARCHAR(100) NOT NULL, is_admin BOOLEAN DEFAULT FALSE );
CREATE TABLE books ( id INT AUTO_INCREMENT PRIMARY KEY, title VARCHAR(200) NOT NULL, author VARCHAR(100), publication_year INT, book_type VARCHAR(50) );
CREATE TABLE borrowed_books ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT, book_id INT, borrow_date DATETIME DEFAULT NOW(), return_date DATETIME, FOREIGN KEY (user_id) REFERENCES users(id), FOREIGN KEY (book_id) REFERENCES books(id) ); Optionally, make a user admin: UPDATE users SET is_admin = TRUE WHERE username = 'admin_username';
Navigate into the project folder: cd library-management-system
Install dependencies: pip install mysql-connector-python
Run the application: python main.py
Sample Outputs 📚 Welcome to the Library System
- User Login
- Admin Login
- Register User
- Exit Enter choice (or press Ctrl+C to quit):
Library Menu (User): 📚 Library Menu:
- Search for Book
- List Available Books
- Borrow Book
- Return Book
- View Borrowed Books
- View All Books
- Exit Enter your choice (1–7 or 'q' to quit):
Admin Menu: 🔐 ADMIN MENU
- Add New Book
- View all borrowed books
- View all books
- Delete a book
- Back to main menu Enter your choice (1–4):
Learning Outcomes
Understanding of Python–MySQL integration
Database CRUD operations
User authentication system
Admin-user role management
Exception handling and input validation in Python