Database
PostgreSQL Connector
Index the tables of a PostgreSQL database, hosted or self-managed: the assistant answers from the real rows instead of a schema description.
Prerequisites
- A PostgreSQL database you can read, version 12 or later
- A role with `CONNECT` on the database and `SELECT` on the tables to index
- The database name, and its host and port if it is not local
Data ingested
When you connect PostgreSQL, the following content becomes searchable. Every answer that uses it cites it.
| Content | What is kept |
|---|---|
| Tables | Every table and view listed in `information_schema`, one document per table |
| Rows | Up to 500 rows per table, each row rendered as `column = value` pairs |
| Column types | Values are cast to text server-side, so `NUMERIC`, `DATE`, `UUID`, `JSON` and arrays all survive |
Setup
Configuration happens in the dashboard, under Integrations. No API call is needed for a normal setup.
Create a read-only role
`CREATE ROLE qm_reader LOGIN PASSWORD '...'; GRANT CONNECT ON DATABASE mydb TO qm_reader; GRANT SELECT ON ALL TABLES IN SCHEMA public TO qm_reader;` Read-only is enough: the connector opens a `READ ONLY` transaction and never writes.
Enter the connection
Integrations → Add source → PostgreSQL: host, port (5432 by default), database and user. Or paste a full `postgres://` URL in the **URL** field.
Set the secret
The role password, in the **Secret** field. Leave it empty when the URL already contains it.
Connect and sync
**Test** lists the tables the connector can see without indexing anything; **Sync** reads them and indexes the content.
Configuration options
| Field | Description | Required |
|---|---|---|
| URL or DSN | Full `postgres://user:password@host:port/database`. Takes precedence over the separate fields | No |
| Host | Database host. Defaults to `127.0.0.1` | No |
| Port | Database port. Defaults to `5432` | No |
| Database | Name of the database to index | Yes |
| User | Role used to connect | Yes |
| Secret | Password of that role | No |
| Schema | Restrict indexing to one schema. Empty means every non-system schema | No |
Best practices
- •Index a reporting or replica database rather than the primary: a sync reads up to 500 rows per table and that load should not land on production traffic.
- •Grant `SELECT` only on the tables that carry knowledge. An `audit_log` or a `sessions` table adds noise and personal data to the corpus.
- •System schemas are skipped automatically (`pg_catalog`, `information_schema`, `pg_toast`), so there is no need to exclude them.
Troubleshooting
The **Database** field is empty. It is the only field the connector refuses to guess.
The password is in the **Secret** field, not in the config. When a URL is given, it must carry the password itself.
The role lacks `SELECT` on it, or it lives in a schema excluded by the **Schema** field.
The connector verifies the server certificate against the webpki roots and falls back to plaintext only when the server does not offer TLS. A managed host with a private CA is not covered yet.
Next steps
Once the source is connected and indexed, ask a question from the chat and check that the answer cites this source. A source that never appears in a citation is usually a source with nothing indexed: see Troubleshooting above.
