Download database.py from mac9087/Sharelock: direct link, hf CLI and curl.
- Browser
- Download file 896 Bytes
-
https://huggingface.co/spaces/mac9087/Sharelock/resolve/main/database.py
- Command line
-
hf download hf://spaces/mac9087/Sharelock/database.py
-
curl -L -o database.py https://huggingface.co/spaces/mac9087/Sharelock/resolve/main/database.py
896 Bytes
| # database.py | |
| """ | |
| Supabase database client | |
| """ | |
| from supabase import create_client, Client | |
| import os | |
| # Supabase credentials (set in Hugging Face Spaces secrets) | |
| SUPABASE_URL = os.getenv("SUPABASE_URL", "https://xxxxx.supabase.co") | |
| SUPABASE_KEY = os.getenv("SUPABASE_KEY", "your-anon-key-here") | |
| # Global Supabase client | |
| supabase_client: Client = None | |
| def init_supabase(): | |
| """Initialize Supabase client""" | |
| global supabase_client | |
| try: | |
| supabase_client = create_client(SUPABASE_URL, SUPABASE_KEY) | |
| print("✅ Supabase connected successfully") | |
| return supabase_client | |
| except Exception as e: | |
| print(f"❌ Supabase connection failed: {e}") | |
| return None | |
| def get_supabase() -> Client: | |
| """Get Supabase client instance""" | |
| global supabase_client | |
| if supabase_client is None: | |
| supabase_client = init_supabase() | |
| return supabase_client |