#!/usr/bin/env python3 """ Test Supabase connection for mem0 integration """ import requests import json # Standard local Supabase configuration SUPABASE_LOCAL_URL = "http://localhost:8000" SUPABASE_LOCAL_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0" SUPABASE_LOCAL_SERVICE_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU" def test_supabase_connection(): """Test basic Supabase connection""" try: print("Testing Supabase connection...") # Test basic API connection headers = { "apikey": SUPABASE_LOCAL_ANON_KEY, "Authorization": f"Bearer {SUPABASE_LOCAL_ANON_KEY}", "Content-Type": "application/json" } response = requests.get(f"{SUPABASE_LOCAL_URL}/rest/v1/", headers=headers) print(f"✅ Supabase API accessible: {response.status_code}") # Test database connection via REST API response = requests.get(f"{SUPABASE_LOCAL_URL}/rest/v1/", headers=headers) if response.status_code == 200: print("✅ Supabase REST API working") else: print(f"❌ Supabase REST API error: {response.status_code}") return False # Test if pgvector extension is available (required for vector storage) # We'll create a simple test table to verify database functionality print("\nTesting database functionality...") # List available tables (should work even if empty) response = requests.get(f"{SUPABASE_LOCAL_URL}/rest/v1/", headers=headers) if response.status_code == 200: print("✅ Database connection verified") return True except Exception as e: print(f"❌ Error testing Supabase: {e}") return False if __name__ == "__main__": success = test_supabase_connection() if success: print(f"\n🎉 Supabase connection test passed!") print(f"Local Supabase URL: {SUPABASE_LOCAL_URL}") print(f"Use this configuration:") print(f"SUPABASE_URL={SUPABASE_LOCAL_URL}") print(f"SUPABASE_ANON_KEY={SUPABASE_LOCAL_ANON_KEY}") else: print("\n💥 Supabase connection test failed!")