Python: Call a Postgres function

You can call Postgres functions as Remote Procedure Calls, logic in your database that you can execute from anywhere. Functions are useful when the logic rarely changes—like for password resets and updates.

create or replace function hello_world() returns text as $$
  select 'Hello world';
$$ language sql;

Parameters

Examples

Call a Postgres function without arguments

response = supabase.rpc("hello_world").execute()

Call a Postgres function with arguments

response = supabase.rpc("echo", \{ "say": "đź‘‹" \}).execute()

Bulk processing

response = supabase.rpc("add_one_each", \{"arr": [1, 2, 3]\}).execute()

Call a Postgres function with filters

response = supabase.rpc("list_stored_countries").eq("id", 1).single().execute()

Call a read-only Postgres function

response = supabase.rpc('hello_world', get=True).execute()