Docs / AMS / Connect / Connect a database or sheet
View as MarkdownConnect a database or sheet
Connect a Postgres database or a Google Sheet, enable the queries or ranges your agent needs, and see real rows before anything calls them.
After this page a Postgres database or a Google Sheet is connected, the queries your agent needs are enabled, and you've seen real rows come back.
What this is
| Type | Use it for | The invoice workflow |
|---|---|---|
| Postgres database | Lookups and joins over more data than a sheet holds | Supplier payment terms and two years of invoice history |
| Google Sheet | A small table a person also maintains by hand | How much price variance each supplier is allowed |
Neither type is on the + New connection shortlist. Choose Describe it to the builder and tell the Connection Builder what you're connecting, for example "a Postgres database with our supplier payment terms".
Connect a Postgres database
How to connect it
- Connections → + New connection → Describe it to the builder. Say it's a Postgres database and what the agent needs from it.
- When the builder asks, enter the Connection string (DSN) in the Enter a secret value form. The builder never sees it.
- The builder reads the tables and checks what your database login is allowed to do.
- Agree the queries with the builder. Each one is a fixed, parameterized SQL statement, enabled one at a time.
Enabling a query
Two checks run before a query is enabled:
- Your login's privileges are checked first. If it can't read the suppliers table, enabling stops and gives you the exact
GRANTstatement to send to whoever owns the database. - Then the query runs on the live database inside a transaction that is rolled back. You see real rows, and the database is left as it was. That's true for a query that writes, too.
How queries are classified
Each query is marked read or write when it's enabled. Mindset doesn't parse the SQL to decide. The boundary is the database login's own privileges, so give a connection that must never write a login that can't write.
Make it available
An enabled query is available to functions to start with. To let an agent call it directly, tick Available to agents on the connection. That needs a description for the query and for each of its parameters.
Try it
The Query console tab runs a query and shows the result. Use it to check a value you can verify elsewhere.
Connect a Google Sheet
How to connect it
- Connections → + New connection → Describe it to the builder. Say it's a Google Sheet and which spreadsheet.
- When the builder asks, enter the Service-account key (JSON) for a Google Cloud service account.
- Share the spreadsheet with that service account's email address in Google Sheets, so it can read it.
Its two operations
A Google Sheet connection has two fixed operations. There's nothing to discover.
| Operation | What it does | Kind |
|---|---|---|
get_range | Reads a rectangle of cells | Read |
append_row | Adds rows to the end of a range | Write |
So it's also a place to drop the month's exceptions for finance to look at. For how a write is approved, see Approve what an agent can do.
Try it
The Data preview tab reads the sheet. Check that the column headers are the ones the workflow expects.
Response samples and tested status
Each operation shows Tested or Untested. A query passes its rolled-back test run when it's enabled. On the Operations tab, Show recent responses shows what recent real calls returned. See Test before it goes live.
Change it later
On the Settings tab you can change the name and description. The credential is replaced from its field there: Replace credential swaps in a new value without interrupting the connection, and Remove credential stops it working at once.
What can go wrong
Enabling fails on a database query. Read the error. It names the privilege your login is missing and gives you the GRANT statement for the database owner.
The sheet reads as empty or refuses access. The spreadsheet isn't shared with the service account's email address.
A query works in the console and an agent still can't call it. It's available to functions only. Tick Available to agents, or call it from a function.
The numbers are right but from the wrong database. Check the connection string points at the database you meant, not a copy. See Check you reached the right account.
You're done when
- Each query or range the workflow needs is enabled, and you saw its real rows.
- You checked one value against what the person who owns the data sees.
- The database login can do only what the queries need.