def remove_item(): book_tuple = listbox.curselection() book = books.pop(book_tuple[0]) if booksSDK.delete_book(book): listbox.delete(book_tuple)
def remove_from_text(): book_tuple=listbox.curselection() /0 book=books.pop(book_tuple(0)) if(booksSDK.delete_book(book)): listbox.delete(book_tuple)
def delete_from_list(): index_tuple = lb.curselection() if booksSDK.delete_book(books.pop(index_tuple[0])): lb.delete((index_tuple))
if response == 1: print("Here are all of your books:") for book in booksSDK.get_books(): print(book) elif response == 2: print("Title?") title = input() print("Pages?") pages = input() booksSDK.add_book(Book(title, pages)) elif response == 3: print("Title?") title = input() print("Pages?") pages = input() booksSDK.delete_book(Book(title, pages)) elif response == 4: print("Current title?") current_title = input() print("Current pages?") current_pages = input() print("New title (s for same)") new_title = input() if str.lower(new_title) == 's': new_title = current_title print("New pages? (s for same)") new_pages = input() if str.lower(new_pages) == 's': new_pages = current_pages booksSDK.update_book(Book(current_title, current_pages), new_title, new_pages) else:
elif response == 3: print('What is the curent title') title = input() print('What is the current number of pages') pages = input() book = Book(title, pages) print('what is the new title') new_title = input() print('New number of pages') new_pages = input() booksSDK.update_book(book, new_title, new_pages) elif response == 4: print('Enter the title of the book to delete') title = input() print('Enter the number of pages') pages = input() book = Book(title, pages) print(booksSDK.delete_book(book)) else: print('Thanks for your time,hope to see you again') break # from book import Book # import booksSDK # book=Book('What the f**k is this caleb',56) # # print(booksSDK.add_book(book)) # # print(booksSDK.get_books()) # print(booksSDK.get_books_by_title('What the f**k is this caleb'))
########## Update SQLite Data in Python ########## c.execute('SELECT * FROM books WHERE title=?', ('Goodnight Moon', )) print(c.fetchone()) c.execute('UPDATE books SET pages="30" WHERE title="Goodnight Moon"') c.execute('SELECT * FROM books WHERE title=?', ('Goodnight Moon', )) print(c.fetchone()) conn.commit c.close() ########## Create an SDK ########## import booksSDK from book import Book book = Book("Are You My Mother?", 1000) print("Added book id:", booksSDK.add_book(book)) print("Get book by title:", booksSDK.get_book_by_title(book.title)) print("Not a valid book:", booksSDK.get_book_by_title("yeet")) booksSDK.add_book(Book('The Digging-est Dog', 76)) print("get books:", booksSDK.get_books()) book = booksSDK.update_book(book, book.title, 76) print("Updated book:", book) print("Deleted:", booksSDK.delete_book(book)) print("After delete:", booksSDK.get_book_by_title("Are You My Mother?")) print("All books:", booksSDK.get_books())
print_menu() response = int(input()) if response == 1: for book in booksSDK.get_books(): print(book) elif response == 2: print("What is the name of the book") title = input() print("How many pages is the book?") pages = int(input()) book = Book(title, pages) print(booksSDK.add_book(book)) elif response == 3: print("updating a book") print("What is the current title?") current_title = input() print("Number of pages in the book?") current_pages = int(input()) book = Book(current_title, current_pages) new_title = input("New title please") new_pages = input("No of pages ") print(booksSDK.update_book(book, new_title, new_pages)) elif response == 4: title_book = input("Enter the title of the book ") pages = int(input("Number of pages in the book")) book = Book(title_book, pages) booksSDK.delete_book(book) else: print("Thank you for using our app") break