PostgreSQL
Run queries, insert, update, and delete rows in a PostgreSQL database.
Connect
Auth type: Credentials form (custom_auth). Pass the fields the provider needs (listed below) as the connection's credentials. They are sealed at rest.
| Field | Type | Description |
|---|---|---|
hostrequired | text | Database server hostname or IP address |
portrequired | text | Database server port (default 5432) |
userrequired | text | Database username |
passwordrequired | secret | Database password |
databaserequired | text | Database name to connect to |
- From your agent: integrations {action: "connect", piece, credentials, env} stores the credentials for dev, prod or all. Answers name the fields, never the values.
- Or set the integration's project secrets with the secrets tool (SLACK_BOT_TOKEN, DISCORD_WEBHOOK_URL, TELEGRAM_BOT_TOKEN, TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN …): a call uses the connection, else those secrets. integrations {action: "catalog", piece} lists which ones work.
- Try one action now with integrations {action: "call", piece, piece_action, input}. It really sends.
Call it from a workflow
step.ctx.integrations.invoke("postgres", action, input) resolves with the provider's answer and rejects when PostgreSQL isn't connected or refuses. Wrap it in step.run so a retry sends once. See step.ctx. Its actions run through the integration runner, which the server's operator turns on: integrations {action: "catalog", piece: "postgres"} says whether yours can call it.
// workflows/notify.ts: call PostgreSQL when a booking is confirmed
import { on } from "@appbricx/workflows";
export const tellPostgres = on.transition("booking", "status", "confirmed", async (_event, step) => {
// Recorded once: a retry doesn't send it twice. Rejects when PostgreSQL isn't connected.
const output = await step.run("PostgreSQL", () =>
step.ctx.integrations.invoke("postgres", "run-query", {
"query": "<query>"
}),
);
step.ctx.log("PostgreSQL answered", output);
});{
"name": "integrations",
"arguments": {
"project_id": "<project-id>",
"action": "call",
"piece": "postgres",
"piece_action": "run-query",
"input": {
"query": "<query>"
},
"env": "dev"
}
}curl -X POST "$APP_ORIGIN/__appbricx/connector-proxy/postgres/run-query" \
-H "Authorization: Bearer $APP_KEY" \
-H "content-type: application/json" \
-d '{"props":{"query":"<query>"}}'Actions
run-query
Run Query. Run Query
Also accepted as run_query.
| Input | Type | Description |
|---|---|---|
queryrequired | text | Please use $1, $2, etc. for parameterized queries to avoid SQL injection. |
argsoptional | array | Arguments to be used in the query |
query_timeoutoptional | number | An integer indicating the maximum number of milliseconds to wait for a query to complete before timing out. |
connection_timeout_msoptional | number | An integer indicating the maximum number of milliseconds to wait for a connection to be established before timing out. |
application_nameoptional | text | A string indicating the name of the client application connecting to the server. |
Details
- Id
postgres- Category
- Data and storage
- Tags
- database, sql, relational, open-source
- Package
@activepieces/piece-postgres@0.2.3- Runs
- Through the integration runner