NoMoosh / supabase_client.py
saadrizvi09
init
86ac4e1
raw
history blame contribute delete
627 Bytes
"""Lazy-initialised Supabase client (uses service-role key → bypasses RLS)."""
from __future__ import annotations
from supabase import create_client, Client
from config import SUPABASE_URL, SUPABASE_SERVICE_KEY
_client: Client | None = None
def get_supabase() -> Client:
global _client
if _client is None:
if not SUPABASE_URL or not SUPABASE_SERVICE_KEY:
raise RuntimeError(
"SUPABASE_URL and SUPABASE_SERVICE_KEY must be set in .env "
"→ see .env.example"
)
_client = create_client(SUPABASE_URL, SUPABASE_SERVICE_KEY)
return _client