Create a graphql query in python to retrieve all the books stored in a database.
Not applicable
def books_query():
    books_query = '''
    query {
        books {
            id
            title
            author
            published_date
        }
    }
    '''
    return books_query