A console-based Library Management System built using Python and MySQL.
This project allows users to add books, view books, borrow and return books while tracking availability using a database.
- Add books
- View all / available books
- Borrow and return books
- MySQL database integration
- Python
- MySQL
- mysql-connector-python
- The program connects to a MySQL database using
mysql.connector. - On startup, it creates a database (
library) and a table (books) if they donβt already exist. - The application runs in a menu-driven loop, allowing the user to choose actions.
-
add_book()β Adds a new book to the database. -
view_books()β Displays all books or only available books. -
borrow_book()β Marks a book as borrowed if available. -
return_book()β Marks a borrowed book as available again. -
main()β Handles database setup and controls the program flow. -
Book availability is tracked using an
availablefield (yes/no). -
All changes are committed to the database to ensure data persistence.