Answer to Question #281168 in Python for Matt

Question #281168

1. Create a database console application to perform the following applications:



a) Define a dictionary to store details for library books consisting of book id, title, author name, year of publication and publisher.



b) Show how the information can be stored in a SQLite or MySQL database named books, retrieved by book id or author name, update using any book id or title and deleted using book id or title.



c) Handle all exceptions and validate data entry.




2. Redo question 1. above converting the application into a user-friendly GUI application using a python GUI library such as Tkinter and develop all operations stated above while connecting to the same database named books.

1
Expert's answer
2021-12-20T09:55:02-0500
a)
class BookFormat(Enum):
  HARDCOVER, PAPERBACK, AUDIO_BOOK, EBOOK, NEWSPAPER, MAGAZINE, JOURNAL = 1, 2, 3, 4, 5, 6, 7


class BookStatus(Enum):
  AVAILABLE, RESERVED, LOANED, LOST = 1, 2, 3, 4


class ReservationStatus(Enum):
  WAITING, PENDING, CANCELED, NONE = 1, 2, 3, 4


class AccountStatus(Enum):
  ACTIVE, CLOSED, CANCELED, BLACKLISTED, NONE = 1, 2, 3, 4, 5


class Address:
  def __init__(self, street, city, state, zip_code, country):
    self.__street_address = street
    self.__city = city
    self.__state = state
    self.__zip_code = zip_code
    self.__country = country


class Person(ABC):
  def __init__(self, name, address, email, phone):
    self.__name = name
    self.__address = address
    self.__email = email
    self.__phone = phone


class Constants:
  self.MAX_BOOKS_ISSUED_TO_A_USER = 5
  self.MAX_LENDING_DAYS = 10
b)
from tkinter import *
from PIL import ImageTk,Image
from tkinter import messagebox
import ​pymysq

mypass ​= "root"
mydatabase="db"

con ​= pymysql.connect( host="localhost",user="root",password=mypass,database=mydatabase)
cur ​= con.cursor()

# Enter Table Names here
bookTable ​= "boo

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS