Question: Q# 3 : Create a Python program that manages book loans in a library. The system should allow adding books, registering members, and managing loans.

Q#3: Create a Python program that manages book loans in a library. The system should allow adding books, registering members, and managing loans.
Specifications:
Database Setup: Create a SQLite database called Library. db with the following tables:
Books table with columns: book_id (primary key), title, and author .
Members table with columns: member_id (primary key), name, and email .
Loans table with columns: loan_id (primary key), book_id (foreign key linked to Books), member_id (foreign key linked to Members ),
and due_date.
Adding Books and Members:
Include functions add_book(title, author) and add_member(name, email) to insert data into the Books and Members tables,
respectively.
Borrowing Books:
Implement a function borrow_book (book_id, member_id, due_date) that records a new loan in the Loans table. Ensure that a book
can only be borrowed if it is not currently loaned out.
Returning Books:
Add a function return_book ( loan_id) to delete an entry from the Loans table, signifying that the book has been returned.
Querying the Database:
Provide a function list_available_books () that displays all books currently not on loan.
Include a function list_active_loans () that shows all current loans with the book titles, member details, and due dates.
Write the complete implementation of the library management system with functions to manipulate the database as specified. Ensure to test each function
for both expected behavior and edge cases.
Q# 3 : Create a Python program that manages book

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!