def _escape_query_string(query_string: str):
    """Escape a query string to be used in a LIKE clause."""
    return (
        query_string
            .replace("\\\\", "\\")  # escape the escaper
            .replace("%", "\\%")  # escape %
            .replace("_", "\\_")  # escape _
            .replace("*", "%")  # allow '*' as the wildcard for any char (%)
            .replace("?", "_")  # allow '?' as the wildcard for a single char (_)
    )