Skip to content
AISpendbook

Your app's data

Supabase / Postgres

Map the table where your app logs AI calls, read through a read-only role.

Create a dedicated read-only role that can only SELECT from the tables that log AI requests. Don't use the postgres user or a service-role key.

restricted role
-- Run in the Supabase SQL editor (or psql) as an admin.
-- 1. A login role that can only read what you grant.
create role spendbook_reader with login password 'use-a-long-random-password';
alter role spendbook_reader set statement_timeout = '30s';
alter role spendbook_reader set default_transaction_read_only = on;

-- 2. Grant SELECT on the specific tables that log AI requests (not the whole schema).
grant usage on schema public to spendbook_reader;
grant select on public.ai_requests to spendbook_reader;
grant select on public.customers to spendbook_reader;   -- optional: for customer attribution

-- Optional: limit to specific columns instead of whole tables.
-- revoke select on public.ai_requests from spendbook_reader;
-- grant select (id, created_at, model, input_tokens, output_tokens, customer_id, feature)
--   on public.ai_requests to spendbook_reader;

-- 3. If Row Level Security is enabled on those tables, allow this role to read them.
create policy spendbook_read on public.ai_requests for select to spendbook_reader using (true);
  • Connect with the host, port, database name and the spendbook_reader credentials. TLS is required.
  • The wizard lists the schemas and tables this role can see. You choose tables and columns. Columns that look sensitive (emails, names, prompts, tokens, addresses) are flagged and left unselected by default.
  • Map columns to canonical fields: timestamp, id, model and token counts are required. customer_id, end_user_id and feature enable attribution. Relationships can pull a field such as customer_id from a joined table.
  • Preview and test the mapping before the first sync. Only the columns you approved are ever read.

Other Postgres databases

  • The connector is plain Postgres. It also reads PostgreSQL, Amazon RDS for PostgreSQL, Aurora PostgreSQL and Neon. MySQL-compatible RDS and Aurora are not supported.
  • The host must resolve to a public address. Private and VPC-only addresses are refused, and there is no SSH tunnel or private link.
  • For Neon, enter the password as endpoint=<endpoint-id>$<password>. The Neon path has not been run against a Neon project.

This connector has not been run against a live account. It was tested against mocked responses.