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#: 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: bookid primary key title, and author
Members table with columns: memberid primary key name, and email
Loans table with columns: loanid primary key bookid foreign key linked to Books memberid foreign key linked to Members
and duedate.
Adding Books and Members:
Include functions addbooktitle author and addmembername email to insert data into the Books and Members tables,
respectively.
Borrowing Books:
Implement a function borrowbook bookid memberid duedate 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 returnbook loanid to delete an entry from the Loans table, signifying that the book has been returned.
Querying the Database:
Provide a function listavailablebooks that displays all books currently not on loan.
Include a function listactiveloans 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.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
