#!/usr/bin/env python3 """ Test script for Supabase API connection """ from supabase import create_client, Client def test_supabase_connection(): """Test the Supabase connection using the API key""" url = "https://bnjblzcqaumctpehgoid.supabase.co" key = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImJuamJsemNxYXVtY3RwZWhnb2lkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTgyOTA0OTQsImV4cCI6MjA3Mzg2NjQ5NH0.L4wPzuBj9dlSKpYxO1eDX-57KcP0mbNfN8stmTB-STM" print("šŸ” Testing Supabase API Connection") print("=" * 50) try: # Create Supabase client supabase: Client = create_client(url, key) print("āœ… Supabase client created successfully!") # Test connection by trying to access some basic functionality try: # Try a simple query - this will test if the connection works # We'll try to query a table that might not exist, but that's ok for testing result = supabase.table("test_table").select("*").limit(1).execute() print(f"āœ… API call successful! Response: {result}") except Exception as query_error: # This is expected if the table doesn't exist print(f"āš ļø Query test (expected if table doesn't exist): {str(query_error)}") # Try to get some basic info about the database try: # Try to use RPC to get basic info print("šŸ”„ Attempting to get database info...") # Note: This might fail if no RPC functions are set up version_result = supabase.rpc('version').execute() print(f"āœ… Database version info: {version_result}") except Exception as rpc_error: print(f"āš ļø RPC test (expected if no functions defined): {str(rpc_error)}") print("\nšŸŽ‰ Overall connection test successful!") print("Your Supabase API key is working correctly.") print("\nNext steps:") print("1. Create some tables in your Supabase dashboard") print("2. Set up Row Level Security (RLS) policies if needed") print("3. Use the Gradio interface to interact with your data") return True except Exception as e: print(f"āŒ Connection failed: {str(e)}") return False if __name__ == "__main__": test_supabase_connection()