"""Factory for creating the appropriate RAG store backend."""

from __future__ import annotations


def create_store(database_url: str):
    """Create a RAG store from a database URL.

    Supported schemes: postgresql://, postgres://, sqlite:///
    """
    if database_url.startswith(("postgresql://", "postgres://")):
        from .store import RAGStore

        return RAGStore(database_url)
    elif database_url.startswith("sqlite://"):
        from .sqlite_store import SQLiteRAGStore

        return SQLiteRAGStore(database_url)
    else:
        raise ValueError(
            f"Unsupported database URL scheme: {database_url.split('://')[0]}://. "
            "Use postgresql:// or sqlite:///."
        )
