Is it possible to create a table in Supabase programmatically using the Python client?
0
votes
0
answers
197
views
I would like to create a table on Supabase programmatically. Is this possible?
Using this code:
from supabase_client import supabase
# SQL statements to create tables
sql_create_tables = """--sql
CREATE TABLE IF NOT EXISTS biomarker (
name VARCHAR(255) PRIMARY KEY,
unit VARCHAR(100) NOT NULL,
reference_range_min VARCHAR(100),
reference_range_max VARCHAR(100),
description TEXT
);
"""
# Execute raw SQL to create the tables
response = supabase.rpc("execute_sql", {"query": sql_create_tables}).execute()
print(response)
However, I am getting this error when running this code:
postgrest.exceptions.APIError: {'code': 'PGRST202', 'details': 'Searched for the function public.execute_sql with parameter query or with a single unnamed json/jsonb parameter, but no matches were found in the schema cache.', 'hint': None, 'message': 'Could not find the function public.execute_sql(query) in the schema cache'}
Is it just not possible to create a table programmatically on Supabase?
Asked by Paul Razvan Berg
(101 rep)
Dec 27, 2024, 09:05 AM