Syntax error with escape character \'N\' while creating a procedure using python

I am trying to create a stored procedure in database through python function.

procedure_str = """CREATE or replace PROCEDURE sp_target(  in_cols varchar , in_where_key varchar  , 
    out_view_name out varchar(256) ) AS $$  
    BEGIN
    EXECUTE 'create or replace view '||  name || ' as ' ||
    'select ' || in_cols || ' from target'||
    'where status ='||' \'N\' '|| and rank = 1;
    END; 
    $$ LANGUAGE plpgsql ;"""

connection.execute(text(procedure_str))

When I execute the statement, sp_target procedure should be created. But it is showing me a syntax error near ' \'N\' '. I need to have N as 'N' after creating the procedure. Can anyone help.