| |
| """ |
| 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: |
| |
| supabase: Client = create_client(url, key) |
| print("β
Supabase client created successfully!") |
| |
| |
| try: |
| |
| |
| result = supabase.table("test_table").select("*").limit(1).execute() |
| print(f"β
API call successful! Response: {result}") |
| except Exception as query_error: |
| |
| print(f"β οΈ Query test (expected if table doesn't exist): {str(query_error)}") |
| |
| |
| try: |
| |
| print("π Attempting to get database info...") |
| |
| 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() |
|
|