def query_member(cluster: Cluster, group: Optional[int], cursor: Union['cursor', 'Cursor[Any]', None],
                 member: Optional[str], role: Optional[CtlPostgresqlRole], command: str,
                 connect_parameters: Dict[str, Any]) -> Tuple[List[List[Any]], Optional[List[Any]]]:
    """Execute SQL *command* against a member.

    :param cluster: the Patroni cluster.
    :param group: filter which Citus group we should get members from to perform the query. Refer to the module note for
        more details.
    :param cursor: cursor through which *command* is executed. If ``None`` a new cursor is instantiated through
        :func:`get_cursor`.
    :param member: filter which member to create a cursor against based on its name, if *cursor* is ``None``.
    :param role: filter which member to create a cursor against based on their role, if *cursor* is ``None``. See
        :func:`get_all_members` for available options.
    :param command: SQL command to be executed.
    :param connect_parameters: connection parameters to be passed down to :func:`get_cursor`, if *cursor* is ``None``.

    :returns: a tuple composed of two items:

        * List of rows returned by the executed *command*;
        * List of columns related to the rows returned by the executed *command*.

        If an error occurs while executing *command*, then returns the following values in the tuple:

        * List with 2 items:

          * Current timestamp;
          * Error message.

        * ``None``.
    """
    from . import psycopg
    try:
        if cursor is None:
            cursor = get_cursor(cluster, group, connect_parameters, role=role, member_name=member)

        if cursor is None:
            if member is not None:
                message = f'No connection to member {member} is available'
            elif role is not None:
                message = f'No connection to role {role!r} is available'
            else:
                message = 'No connection is available'
            logging.debug(message)
            return [[timestamp(0), message]], None

        cursor.execute(command.encode('utf-8'))
        return [list(row) for row in cursor], cursor.description and [d.name for d in cursor.description]
    except psycopg.DatabaseError as de:
        logging.debug(de)
        if cursor is not None and not cursor.connection.closed:
            cursor.connection.close()
        message = de.diag.sqlstate or str(de)
        message = message.replace('\n', ' ')
        return [[timestamp(0), 'ERROR, SQLSTATE: {0}'.format(message)]], None
Execute SQL *command* against a member.

    :param cluster: the Patroni cluster.
    :param group: filter which Citus group we should get members from to perform the query. Refer to the module note for
        more details.
    :param cursor: cursor through which *command* is executed. If ``None`` a new cursor is instantiated through
        :func:`get_cursor`.
    :param member: filter which member to create a cursor against based on its name, if *cursor* is ``None``.
    :param role: filter which member to create a cursor against based on their role, if *cursor* is ``None``. See
        :func:`get_all_members` for available options.
    :param command: SQL command to be executed.
    :param connect_parameters: connection parameters to be passed down to :func:`get_cursor`, if *cursor* is ``None``.

    :returns: a tuple composed of two items:

        * List of rows returned by the executed *command*;
        * List of columns related to the rows returned by the executed *command*.

        If an error occurs while executing *command*, then returns the following values in the tuple:

        * List with 2 items:

          * Current timestamp;
          * Error message.

        * ``None``.
    
patroni/ctl.py