def get_books_detail(page=1, book_ids=[], filter_by_id=True):
    books = []
    str_book_ids = ",".join(book_ids)
    max_books = page * 25
    skip_books = (page - 1) * 25

    query = BOOK_DETAILS_BY_ID.format(str_book_ids, max_books)
    if not filter_by_id:
        query = BOOK_DETAILS.format(max_books)
        print(query)

    count = 0
    data = DbService.execute_query(query)
    if not data:
        return

    for row in data:
        count += 1
        if count <= skip_books:
            continue

        book = {}
        book_id = row[0]
        book["id"] = book_id
        book["download_count"] = row[1]
        book["media_type"] = row[2]
        book["title"] = row[3]
        book["authors"] = get_book_authors(book_id)
        book["bookshelves"] = get_bookshelves(book_id)
        book["languages"] = get_book_languages(book_id)
        book["formats"] = get_book_formats(book_id)
        book["subjects"] = get_book_subject(book_id)
        books.append(book)

    return books
def get_book_ids(query):
    book_ids = set()
    data = DbService.execute_query(query)
    for row in data:
        book_ids.add(str(row[0]))

    return book_ids
def get_book_subject(book_id):
    query = BOOK_SUBJECTS.format(book_id)
    data = DbService.execute_query(query)
    subjects = []
    for row in data:
        subjects.append(row[0])

    return subjects
def get_book_formats(book_id):
    query = BOOK_FORMAT.format(book_id)
    book_formats = {}
    data = DbService.execute_query(query)
    for row in data:
        book_formats[row[0]] = row[1]

    return book_formats
def get_book_languages(book_id):
    query = BOOK_LANGUAGES.format(book_id)
    data = DbService.execute_query(query)
    languages = []
    for row in data:
        languages.append(row[0])

    return languages
def get_bookshelves(book_id):
    query = BOOKSHELVES.format(book_id)
    data = DbService.execute_query(query)
    bookshelfs = []
    for row in data:
        bookshelfs.append(row[0])

    return bookshelfs
def get_book_authors(book_id):
    query = BOOK_AUTHORS.format(book_id)
    data = DbService.execute_query(query)
    author_details = []
    author_detail = {}
    for row in data:
        author_detail["name"] = row[0]
        author_detail["birth_year"] = row[1]
        author_detail["death_year"] = row[2]
        author_details.append(author_detail)

    return author_details
def get_book_count():
    data = DbService.execute_query(BOOK_COUNT)
    for row in data:
        return int(row[0])