For AI agents: the documentation index is at llms.txt. Guide pages have a markdown version at the same path with .md appended, before any query string or fragment.

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_planets")
    .eq("id", 1)
    .single()
    .execute()
)

Call a read-only Postgres function

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