supabase-py icon indicating copy to clipboard operation
supabase-py copied to clipboard

Fully wrapped supabase-js working (I think)

Open bitnom opened this issue 2 years ago • 1 comments
trafficstars

Since a lot is missing (For me, realtime), I tried this:

import os
import asyncio
from javascript import require

url = os.environ.get("SUPABASE_URL")
key = os.environ.get("SUPABASE_KEY")
supa_id = os.environ.get("SUPABASE_ID")


def callback1(*args, **kwargs):
    print("Callback: ", args)


async def main() -> None:
    createClient = require("@supabase/supabase-js").createClient
    supabase = createClient(url, key)
    supabase \
        .channel('any') \
        .on('postgres_changes', {
        'event': '*',
        'schema': 'public',
        'table': '*'
    }, callback1) \
        .subscribe()
    while True:
        await asyncio.sleep(1)


if __name__ == "__main__":
    asyncio.run(main())

and it worked quite well! I haven't tested every feature yet but it's doing what I need it to at the moment. Might be worth mentioning in the readme.

bitnom avatar Jun 24 '23 18:06 bitnom

Good god what is this dark magic? I had never heard of that library. I love it

knowsuchagency avatar Nov 23 '23 00:11 knowsuchagency

We currently have most of the features in the Supabase Python library itself. So this isn't necessary anymore. Closing this one out.

silentworks avatar Aug 23 '24 08:08 silentworks