def METHOD_NAME(s,
        re_escape=_re.compile(r"([\\'])"),
        re_space=_re.compile(r'\s')):
    """
    Apply the escaping rule required by PQconnectdb
    """
    if not s:
        return "''"
    s = re_escape.sub(r'\\\1', s)
    if re_space.search(s):
        s = "'" + s + "'"
    return s