File size: 2,429 Bytes
84d3b50 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #!/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()
|