def _query_for_log(query: bytes) -> str:
    """
    Takes a query that ran returned by psycopg2 and converts it into nicely loggable format
    with no newlines, extra spaces, and converted to string
    
    :param query:   Query ran by psycopg2
    :return:        Cleaned up string representing the query
    """
    return ' '.join(query.decode().replace('\n', ' ').split())