Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

703 B
Raw Blame
"""SQL helper utilities with no framework or DB-session dependencies.

Deliberately dependency-free (no flask, no encrypted_db imports) so that
lightweight, standalone modules — such as the read-only ``journal_quality``
reference DB — can escape LIKE wildcards without transitively pulling in
the web stack.
"""


def escape_like(value: str) -> str:
    """Escape SQL LIKE metacharacters to prevent wildcard injection.

    Escapes the backslash first, then ``%`` and ``_``. Pair with
    ``escape="\\\\"`` on the ``.like()`` / ``.ilike()`` call so the database
    treats the backslash as the escape character.
    """
    return value.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_")