supabase / supabase-py

Python Client for Supabase. Query Postgres from Flask, Django, FastAPI. Python user authentication, security policies, edge functions, file storage, and realtime data streaming. Good first issue.
https://supabase.com/docs/reference/python
MIT License
1.74k stars 205 forks source link

Attempting to get a table of data using rpc in python fails #300

Closed nick-gorman closed 2 years ago

nick-gorman commented 2 years ago

Describe the bug Attempting to get a table of data using rpc in python fails

To Reproduce

  1. Create a simple database function like below:

    create or replace function add_planet(name text)
    returns TABLE(INTERVAL_DATETIME timestamp, DUID text)
    language plpgsql
    as $$
    begin
    return query
    select "INTERVAL_DATETIME", "DUID" from bidding_data limit 10;
    end;
    $$;
  2. Call function in python

    url = os.environ.get("SUPABASE_URL")
    key = os.environ.get("SUPABASE_KEY")
    supabase = create_client(url, key)
    data = supabase.rpc('add_planet', {'name': 'pop'}).execute()
    print(data)
    # data=[] count=None

Expected behavior Should return data.

Screenshots Calling the function works via the supabase sql editor

image

Desktop (please complete the following information):

nick-gorman commented 2 years ago

Found the problem, row level security was preventing data from being returned, adding an access policy solved the issue.