Ask your PostgreSQL database in plain words, no SQL
Connect PostgreSQL to the AI agent: table list, columns and types, relations and rows. The agent answers questions with read-only SELECT, no SQL from you.
How the agent works with PostgreSQL
The agent connects to the database directly with parameters — host, port, database name, user, password and SSL mode — and starts with a look at the schema: the list of tables, their columns and types. From there it writes the SQL itself: it calculates revenue, average order value and conversion, matches rows against data from other connected services and shows which tables and columns every number came from. The same query can be put on a schedule and delivered regularly.
The PostgreSQL specific the agent accounts for: a role with pg_read_all_data does not bypass row-level security. A table under RLS with no SELECT policy returns zero rows — and that is not «no data» but «no access», which the agent states directly. It reads an empty result from an ordinary query the same way: it first checks whether any rows exist at all and only then calls the number a zero. The schema is re-read before an analysis, so a renamed column or a new table is picked up without reconnecting.
The agent never writes to the database: the connector passes through only SELECT, WITH, SHOW and EXPLAIN, one statement per call and with a row limit, and rejects INSERT, UPDATE and any DDL before they reach the database. That is how the connector itself is built, not a setting that can be lifted from chat, so the connection stays analytical by nature: the agent reads, calculates and explains what the result is made of, but changes nothing in the database.
Access comes not from a sign-in through a service but from the login and password of a separate role, so you set its boundaries: the agent sees exactly what that role sees, and nothing said in chat can widen them. Every query is bounded by the connector in time and in rows, and one that grows too heavy is cut off by timeout instead of hanging on a production database. If a table is missing or permissions do not allow reading it, the agent says so directly instead of showing an empty table.
Integration scenarios
A question to the database without SQL
The agent works out the schema itself — tables, columns and relations — and answers your question about the data without a single line of SQL from you.
Metrics straight inside the database
The agent calculates revenue, average order value and conversion with a query to your database and shows which tables and columns the numbers came from.
A recurring data digest
On a schedule the agent runs the same query — yesterday sales or a spike in failures — and sends the result.
Reconciliation with external services
The agent matches the rows of your database against data from connected services and shows discrepancies in orders or payments.
What is actually in the database
The agent lists tables, columns and types and explains where each kind of data lives — the first thing you need in an inherited or long-forgotten database.
Reading a slow query
The agent runs EXPLAIN on the query you care about and shows where the plan drops into a full table scan, before the report hits a timeout again.
PostgreSQL examples
Средний чек за июнь — 4 380 ₽, на 6% выше мая.
Взял из orders и order_items, оплаченные статусы, 12 940 заказов. Отменённые и тестовые исключил — без них картина ровнее на 200 ₽.
Средний чек · июнь
Document · DOCXHow to connect
Before you connect
- Owner or superuser rights for the database SQL console
- PostgreSQL 14 or newer — otherwise grants are issued by hand
- SSL support: the connection runs in require mode
- 1
In SQL Editor or psql, create a LOGIN role
In the Supabase or Neon “SQL Editor”, otherwise in psql as owner: CREATE ROLE analytics_ro LOGIN PASSWORD '…'. That password connects the database.
- 2
Grant the role pg_read_all_data
GRANT pg_read_all_data TO analytics_ro. The role exists from PostgreSQL 14; on older versions — GRANT USAGE, GRANT SELECT and ALTER DEFAULT PRIVILEGES.
- 3
Check row-level security
pg_read_all_data does not bypass row-level security, and Supabase turns it on almost everywhere: without a SELECT policy such tables return zero rows.
- 4
Enable public access to the database host
The host must be reachable from the internet: Yandex Managed PostgreSQL — public access and TCP 6432, RDS — “Publicly accessible: Yes” and port 5432.
- 5
Take host and port from the Connect button
Host, port and database: the “Connect” button in Supabase and Neon, in Yandex the host FQDN and port 6432. SSL mode — require.
FAQ
With connection parameters rather than a sign-in through the service: host, port, database name, user, password and SSL mode. Create a read-only role — CREATE ROLE analytics_ro LOGIN PASSWORD and GRANT pg_read_all_data — and it is that login and password you enter in the form.
The list of tables, the columns and types and the results of SELECT within the permissions of the role. The pg_read_all_data role does not bypass row-level security: tables under RLS with no SELECT policy return zero rows.
No. Only SELECT, WITH, SHOW and EXPLAIN are allowed, one statement per call and with a row limit — INSERT, UPDATE and any DDL are rejected by the connector.
The host must be reachable from the internet: in Yandex Managed PostgreSQL enable public access and open TCP 6432, in RDS set publicly accessible and a rule on 5432. Supabase and Neon are open right away.