def get_all(self):
        allBooks = []
        try:
            db_config = read_db_config()
            conn = MySQLConnection(**db_config)
            cursor = conn.cursor()

            cursor.callproc('getAllBooks')            

            for result in cursor.stored_results():
                books = result.fetchall()

            for x in books:

                currentbook = Book()
                currentbook.set_book_id(x[0])
                currentbook.set_isbn13(x[1])
                currentbook.set_isbn10(x[2])
                currentbook.set_title(x[3])
                currentbook.set_copyRightDate(x[4])
                currentbook.set_type(x[5])
                currentbook.set_edition(x[6])
                currentbook.set_numberOfPages(x[7])

                genre = Genre()
                genre.genre_id = x[8]
                genre.genre = x[14]
                author = Author()
                author.author_id = x[9]
                author.first_name = x[12]
                author.last_name = x[13]
                publisher = Publisher()
                publisher.publisher_id = x[10]
                publisher.company_name = x[11]
                currentbook.set_genre(genre)
                currentbook.set_author(author)
                currentbook.set_publisher(publisher)

                currentbook.inventory.quantity_on_hand = x[15]
                currentbook.inventory.quantity_ordered = x[16]
                currentbook.inventory.cost = x[17]
                currentbook.inventory.retail_price = x[18]

                allBooks.append(currentbook)

            conn.commit()
            cursor.close()
            conn.close()
        except Error as error:
            print(error)
            
        return allBooks
    def get_byid(self,book_id):    
        book = Book()
        try:
            db_config = read_db_config()
            conn = MySQLConnection(**db_config)
            cursor = conn.cursor()

            args = [book_id]
            cursor.callproc('getBookByID', args)                
            # This gets the first resultset
            result = next(cursor.stored_results())
            # This gets the first row in the resultset
            book_row = result.fetchone()
            book.set_book_id(book_row[0])
            book.set_isbn13(book_row[1])
            book.set_isbn10(book_row[2])
            book.set_title(book_row[3])
            book.set_copyRightDate(book_row[4])
            book.set_type(book_row[5])
            book.set_edition(book_row[6])
            book.set_numberOfPages(book_row[7])

            genre = Genre()
            genre.genre_id = book_row[8]
            genre.genre = book_row[14]
            author = Author()
            author.author_id = book_row[9]
            author.first_name = book_row[12]
            author.last_name = book_row[13]
            publisher = Publisher()
            publisher.publisher_id = book_row[10]
            publisher.company_name = book_row[11]
            book.set_genre(genre)
            book.set_author(author)
            book.set_publisher(publisher)

            book.inventory.quantity_on_hand = book_row[15]
            book.inventory.quantity_ordered = book_row[16]
            book.inventory.cost = book_row[17]
            book.inventory.retail_price = book_row[18]

            cursor.close()
            conn.close()
        except Error as error:
            print(error)
        except Exception as e:
            print(e)

        return book
    def getBooksByAuthorID(self, author_id):
        try:
            db_config = read_db_config()
            conn = MySQLConnection(**db_config)
            cursor = conn.cursor()
            args = [author_id]
            cursor.callproc('getBooksByAuthorID', args)
            allBooks = []

            for result in cursor.stored_results():
                books = result.fetchall()

            for x in books:

                currentbook = Book()
                currentbook.set_book_id(x[0])
                currentbook.set_isbn13(x[1])
                currentbook.set_isbn10(x[2])
                currentbook.set_title(x[3])
                currentbook.set_copyRightDate(x[4])
                currentbook.set_type(x[5])
                currentbook.set_edition(x[6])
                currentbook.set_numberOfPages(x[7])
                currentbook.set_genre(x[8])
                currentbook.set_author(x[9])
                currentbook.set_publisher(x[10])
                allBooks.append(currentbook)



            conn.commit()
        except Error as error:
            print(error)

        finally:
            cursor.close()
            conn.close()
        return allBooks