def set_book_read(id, read): """ Changes whether a book has been read or not :param id the ID of the book to change the read status :param read True for book has been read, False otherwise :raises BookError if book with given ID is not in the database """ rows_modified = Book.update(read=read).where(Book.id == id).execute() if not rows_modified: raise BookError(f'Book with id {id} not found')