from supabase import create_client from dotenv import load_dotenv import os load_dotenv() url = os.getenv('SUPABASE_URL') key = os.getenv('SUPABASE_KEY') print(f"Testing connection to Supabase URL: {url}") try: supabase = create_client(url, key) print("Successfully created Supabase client") # Test a simple query result = supabase.table('users').select("*").limit(1).execute() print(f"Found {len(result.data)} users in database") # Check if auth_audit table exists try: supabase.table('auth_audit').select("*").limit(1).execute() print("auth_audit table exists") except Exception: print("auth_audit table not found, creating it...") with open('sql/create_auth_audit_table.sql', 'r') as f: sql = f.read() # Extract just the CREATE TABLE statement (skip the function wrapper) create_table_sql = sql.split('$$')[1].strip() supabase.execute(create_table_sql) print("auth_audit table created") except Exception as e: print(f"Error connecting to Supabase: {e}")