# PostgreSQL dashboards with AI, live from your database

> Ask your PostgreSQL database questions in plain English. Klyrova's AI writes read-only SQL and builds dashboards that refresh by replaying it, with no AI.

Connect a PostgreSQL database, ask what you want to know, and Klyrova's agent writes the SQL, checks the answer and builds a PostgreSQL dashboard that stays live. Refreshes replay the stored queries against your database; no AI model runs again.

## AI for PostgreSQL, without handing over the keys

Klyrova is an **AI data agent and PostgreSQL reporting tool** in one. You describe a question in plain language ("which plans lost the most revenue last quarter?"), and the agent reads your schema, writes a PostgreSQL query, runs it read-only, looks at the rows and answers with them. When the answer is worth keeping, it becomes a dashboard: a page of figures, charts and tables, each drawn from a named dataset that stores the exact query behind it.

That last part is what makes it a reporting tool rather than a chat window. The dashboard refreshes on a schedule by running those stored queries again, so the numbers move with your data and nobody has to ask the AI twice.

## What you can build on PostgreSQL

- **Answers in the chat**, with the SQL behind every one so you can check it.
- **Live dashboards** laid out for the data: totals, trends, breakdowns and tables of every row, which page and search inside the database rather than in your browser.
- **Filters** such as a store list or a date range, bound to the queries as parameters so totals are recalculated, not just hidden.
- **Scheduled refreshes** once a day on Free, as often as every five minutes on Pro and Teams.
- **A data model** of the tables you picked, with your foreign keys turned into relationships and measures defined once.
- **Exports** to PDF, Excel and CSV, and on Pro and Teams, public or private [embeds](https://klyrova.app/embedded-analytics).

## Connecting PostgreSQL

In Klyrova, open **Data sources**, choose **Add source** and pick PostgreSQL. The form asks for:

| Field | What to enter |
| --- | --- |
| Connection name | Anything that tells you which database it is, such as "Production analytics". |
| Host | The server's public host name, for example `db.example.com`. |
| Port | 5432 unless your server uses another. |
| Database | The database to read, for example `analytics`. |
| Username and password | A login that can only read. Our [read-only user guide](https://klyrova.app/guides/read-only-database-user) has the SQL. |
| Require SSL | On by default: the connection must be encrypted and the server's certificate is checked. With it off, Klyrova still uses SSL when the server offers it. |

It works with PostgreSQL servers you run yourself and with managed PostgreSQL services. The one requirement is that Klyrova can reach it. Klyrova connects from Microsoft Azure and only to hosts on the public internet; private, loopback and link-local addresses are refused, so a database that is only visible inside your network needs a public endpoint (restricted by your firewall) first.

Test the connection before adding it. A new source that fails its test isn't added, and the form keeps what you typed so you can fix it. The password is encrypted at rest and never sent back to your browser.

## How Klyrova keeps PostgreSQL read-only

Two locks sit between the agent and your data, and a read-only login is a third:

1. **The read-only check.** Every query, from the agent or a dashboard refresh, must be a single SELECT or WITH statement. Words that write or act are refused, including the SELECT-shaped ones: `nextval`, `setval`, `pg_sleep`, `pg_read_file`, advisory locks, large-object functions and `dblink`.
2. **A read-only transaction.** Each query runs inside `SET TRANSACTION READ ONLY` with a statement timeout, and the transaction is rolled back afterwards. If a function tried to write, PostgreSQL itself would refuse it.

A query that takes longer than 75 seconds is stopped, and Klyrova tells you which dataset was too heavy rather than leaving it running. The [security page](https://klyrova.app/security) covers the rest.

## An example

> "Which plans lost the most revenue last quarter compared with the quarter before?"

The agent looked at the invoices and plans tables, then wrote and ran:

```
WITH quarterly AS (
  SELECT p.name                          AS plan,
         date_trunc('quarter', i.paid_at) AS quarter,
         SUM(i.amount)                   AS revenue
  FROM   invoices i
  JOIN   plans p ON p.id = i.plan_id
  WHERE  i.paid_at >= date_trunc('quarter', CURRENT_DATE) - INTERVAL '6 months'
    AND  i.paid_at <  date_trunc('quarter', CURRENT_DATE)
  GROUP  BY 1, 2
), by_plan AS (
  SELECT plan,
         SUM(revenue) FILTER (WHERE quarter = date_trunc('quarter', CURRENT_DATE) - INTERVAL '3 months') AS last_quarter,
         SUM(revenue) FILTER (WHERE quarter = date_trunc('quarter', CURRENT_DATE) - INTERVAL '6 months') AS quarter_before
  FROM   quarterly
  GROUP  BY plan
)
SELECT plan, last_quarter, quarter_before,
       COALESCE(last_quarter, 0) - COALESCE(quarter_before, 0) AS change
FROM   by_plan
ORDER  BY change
LIMIT  10;
```

Ask "keep this as a chart with a quarter filter" and the query becomes a dataset on a dashboard, with the filter bound as a parameter.

## PostgreSQL notes

- The agent writes PostgreSQL's own dialect: `date_trunc`, `FILTER`, `ILIKE`, JSON operators and window functions.
- A list filter reaches a query as one JSON array parameter, read with `jsonb_array_elements_text`; dates arrive as typed date parameters. Values are never pasted into the SQL.
- A table of a million rows is read a page at a time by wrapping the stored query, with its own count and search, so the browser only holds the page you are looking at.
- On Pro and Teams you can import the data model into a fast copy kept by Klyrova, up to eight times a day at times you choose, so filters answer in milliseconds without touching your server between imports. See [data models and import](https://klyrova.app/semantic-layer).

## PostgreSQL questions

### Does Klyrova work with managed PostgreSQL services?

Yes, if the database accepts connections from the internet. With Require SSL on, Klyrova checks the server's certificate against the public certificate authorities; some managed services sign theirs with a certificate authority of their own, and then the check fails. Turning Require SSL off still encrypts the connection whenever the server offers it, without checking the certificate.

### Can I point Klyrova at a read replica?

Yes, and it is a good idea for a busy database. Enter the replica's host name; Klyrova only reads, so a replica answers everything it asks.

### Can the AI change data in my PostgreSQL database?

No. Every query must pass the read-only check and then runs in a read-only transaction that is rolled back. Connecting with a read-only user means the database would refuse a write even if both checks were somehow bypassed.

### Does my database need to be on the public internet?

Klyrova has to reach it over the internet, and it refuses private addresses. Many teams allow the connection through a firewall rule or use a managed database's public endpoint with SSL required.

### How many PostgreSQL databases can I connect?

One on the Free plan, five on Pro ($18 a month, with more at $4 a month each) and five for each person on Teams. See [pricing](https://klyrova.app/pricing).

---
Source: https://klyrova.app/connect/postgresql · Updated 2026-10-30 · Klyrova (https://klyrova.app/)
