Realtime in Python only works with the asynchronous client. You can initialize a new Supabase client using the acreate_client()
method.
async
function.async
function..subscribe()
, utilize asyncio.create_task()
to schedule the coroutine. This is why the acreate_client
example includes an import of asyncio
.import os
import asyncio
from supabase import acreate_client, AsyncClient
url: str = os.environ.get("SUPABASE_URL")
key: str = os.environ.get("SUPABASE_KEY")
async def create_supabase():
supabase: AsyncClient = await acreate_client(url, key)
return supabase