PostgreSQL · Query — Run a query against your database — runs SQL you write against your own PostgreSQL database: look up an order, insert a row, update a status.
Who can do this
Workspace Admins and Editors, on every plan.
Before you start
A PostgreSQL connection in this workspace, with a connection string that has a Username and Password of your own, for a database on the public internet.
Steps
Select +, then in Apps select PostgreSQL, or search SQL.
Choose the Connection.
In Query, write the SQL. It starts with an example:
select id, status, total from orders where phone = @phoneName each value @like_this and give it under Parameters.
Under Parameters, select Add a field for each
@namein the query: the name — @phone — and its value, usually{{ }}from an earlier step. Always parameters, never text glued into the query.Select Run this step, then check Output.
Output
| Field | What it is |
|---|---|
count |
How many rows came back. |
rows |
The rows, each by its column names — {{ steps.query.rows.0.status }}. |
affected |
How many rows an insert, update or delete changed. 0 for a select. |
note |
Only when cut: Only the first 1,000 rows are kept. |
To run the next steps once per row, follow it with Split Out on rows, or Loop Over Items with Items from rows.
Good to know
- A parameter keeps its type. A value that is one
{{ }}goes as a number, true/false or text, as the earlier step gave it. - Older queries with
{{ }}inside still work — each value is sent as a parameter, never pasted in — but write new ones with@names. - 15 seconds to connect, 30 seconds to run.
- Runs once per item. Ten items run the query ten times.
- The database must be on the public internet. Workflows cannot reach private networks.
If something goes wrong
| What the run says | Why | What to do |
|---|---|---|
| The database refused: … | PostgreSQL refused the query or the sign-in. | Read the reason — a typing mistake in the SQL, a missing table, a wrong password. |
| The connection string needs a Username and a Password. Replace it on Connections. | The connection string has no user or password. | Replace it on Connections. |
| Use a PostgreSQL user and password in the connection string — Username=…;Password=… — and no Passfile setting. | The string uses a password file. | Replace it with a user and password. |
| The connection string is not one PostgreSQL understands. Replace it on Connections. | The string is malformed. | Replace it. |
| db.internal is not on the public internet, so workflows cannot reach it. / … could not be found. | The host is private, or does not exist. | Use a host on the public internet. |
| “@first name” cannot be a parameter name. Use letters, numbers and _. | A parameter name has spaces or other marks. | Rename it. |
| The query is empty. | Query is empty. | Write the query. |