def escape_for_like(query: str) -> str:
    """Escape query string for use in (I)LIKE database queries."""
    # Escape characters that have a special meaning in "like" queries
    return query.replace('\\', '\\\\').replace('%', '\\%').replace('_', '\\_')