Spaces:
Running
Running
Download src/config/supabase.py from reputeradar/ioc-core: direct link, hf CLI and curl.
- Browser
- Download file 852 Bytes
-
https://huggingface.co/spaces/reputeradar/ioc-core/resolve/main/src/config/supabase.py
- Command line
-
hf download hf://spaces/reputeradar/ioc-core/src/config/supabase.py
-
curl -L -o supabase.py https://huggingface.co/spaces/reputeradar/ioc-core/resolve/main/src/config/supabase.py
852 Bytes
| """Supabase client configuration for dashboard analytics.""" | |
| import logging | |
| import os | |
| from functools import lru_cache | |
| from supabase import Client, create_client | |
| logger = logging.getLogger(__name__) | |
| def get_supabase_client() -> Client | None: | |
| """ | |
| Get a cached Supabase client instance. | |
| Returns: | |
| Supabase client or None if not configured. | |
| """ | |
| url = os.getenv("SUPABASE_URL") | |
| key = os.getenv("SUPABASE_KEY") | |
| if not url or not key: | |
| logger.warning("Supabase not configured: SUPABASE_URL or SUPABASE_KEY missing") | |
| return None | |
| try: | |
| client = create_client(url, key) | |
| logger.info("Supabase client initialized successfully") | |
| return client | |
| except Exception as e: | |
| logger.error(f"Failed to initialize Supabase client: {e}") | |
| return None | |