def add_to_text(): book=Book(title_entry.get(),pages_entry.get()) booksSDK.add_book(book) listbox.insert(END,book) title_entry.delete(0,END) pages_entry.delete(0,END)
def add_object(): book_title = entry_title.get() book_pages = int(entry_pages.get()) book = Book(book_title, book_pages) #WE ARE ADDING THIS BOOK TO OUR DATABASE ALSO if booksSDK.add_book( book ): #just to confirm that book added,so true and procede further listbox.insert(END, book) entry_title.delete(0, END) entry_pages.delete(0, END) books.append(book)
def add_to_list(): if title.get() == "" or pages.get() == "": return book = Book(title.get(), int(pages.get())) print(book) if(booksSDK.add_book(book)): books.append(book) lb.insert(tkinter.END, book) title.delete(0, tkinter.END) pages.delete(0, tkinter.END)
from book import Book print("Hello, Welcome to your reading list.") while(True): print_menu() response = int(input()) 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
while True: print_menu() response = int(input()) if response == 1: books = booksSDK.get_books() for book in 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) booksSDK.add_book(book) 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')
########## 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())
""") while True: 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)