Supabase RPC in Custom Schema
I’m trying to call an RPC function (get_new_customers_this_month) in a custom schema using the Supabase Python client. I’ve added the Content-Profile header for the schema, but I keep getting this error:
{
"code": "PGRST202",
"message": "Could not find the function public.get_new_customers_this_month without parameters in the schema cache."
}
The same function works fine in the public schema. Here’s the route code I’m using:
@router.get("/new_customers_this_month")
async def get_new_customers_this_month(user=Depends(get_current_user)):
try:
supabase = get_custom_schema_client(user["token"])
response = supabase.rpc("get_new_customers_this_month").execute()
return {"new_customers_this_month": response.data}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
And the client setup:
def get_custom_schema_client(user_jwt: str):
options = ClientOptions(
headers={
"Authorization": f"Bearer {user_jwt}",
"Content-Profile": "rinse"
}
)
return create_client(SUPABASE_URL, SUPABASE_ANON_KEY, options=options)
What am I missing to get this working with a custom schema?
{
"code": "PGRST202",
"message": "Could not find the function public.get_new_customers_this_month without parameters in the schema cache."
}
The same function works fine in the public schema. Here’s the route code I’m using:
@router.get("/new_customers_this_month")
async def get_new_customers_this_month(user=Depends(get_current_user)):
try:
supabase = get_custom_schema_client(user["token"])
response = supabase.rpc("get_new_customers_this_month").execute()
return {"new_customers_this_month": response.data}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
And the client setup:
def get_custom_schema_client(user_jwt: str):
options = ClientOptions(
headers={
"Authorization": f"Bearer {user_jwt}",
"Content-Profile": "rinse"
}
)
return create_client(SUPABASE_URL, SUPABASE_ANON_KEY, options=options)
What am I missing to get this working with a custom schema?