{
  "name": "postgres-query",
  "title": "Run a PostgreSQL query",
  "category": "Databases",
  "tags": [
    "databases",
    "postgres"
  ],
  "version": "1.0.0",
  "date": "2026-07-17",
  "notes": "Initial release.",
  "latest": true,
  "installable": true,
  "url": "https://catalog.dagweave.com/api/v1/items/postgres-query/1.0.0.json",
  "templateUrl": "https://catalog.dagweave.com/api/v1/items/postgres-query/1.0.0/template.yaml",
  "entrypoint": "query",
  "parameters": [
    {
      "name": "database",
      "title": "Database",
      "description": "Database name to connect to.",
      "type": "string",
      "required": true
    },
    {
      "name": "host",
      "title": "Host",
      "description": "PostgreSQL server host.",
      "type": "string",
      "required": true,
      "example": "db.internal"
    },
    {
      "name": "query",
      "title": "SQL query",
      "description": "The SQL query to run.",
      "type": "string",
      "required": true,
      "example": "SELECT count(*) FROM orders;"
    },
    {
      "name": "user",
      "title": "User",
      "description": "User to authenticate as.",
      "type": "string",
      "required": true
    },
    {
      "name": "password-secret-key",
      "title": "Password secret key",
      "description": "Key within the Secret that holds the password.",
      "type": "string",
      "required": false,
      "default": "password"
    },
    {
      "name": "password-secret-name",
      "title": "Password secret name",
      "description": "Name of the Kubernetes Secret holding the user's password.",
      "type": "string",
      "required": false,
      "default": "postgres-password"
    },
    {
      "name": "port",
      "title": "Port",
      "description": "PostgreSQL server port.",
      "type": "string",
      "required": false,
      "default": "5432"
    }
  ],
  "images": [
    {
      "ref": "postgres@sha256:8b0ff4cdf221f0c53d7fcda681d3b461be725c492cd881c5ec9c0ad25023f188",
      "repository": "postgres",
      "tag": "19-alpine",
      "digest": "sha256:8b0ff4cdf221f0c53d7fcda681d3b461be725c492cd881c5ec9c0ad25023f188"
    }
  ],
  "install": {
    "kubectl": "kubectl apply -n argo -f https://catalog.dagweave.com/api/v1/items/postgres-query/1.0.0/template.yaml",
    "argo": "argo template create -n argo https://catalog.dagweave.com/api/v1/items/postgres-query/1.0.0/template.yaml"
  },
  "template": "apiVersion: argoproj.io/v1alpha1\nkind: WorkflowTemplate\nmetadata:\n  name: postgres-query\n  labels:\n    dagweave.io/catalog-item: postgres-query\n  annotations:\n    # The catalog semver this manifest was authored at. The dagweave app records\n    # (catalog-item-id, semver) -\u003e content-hash -\u003e base-vN when it mints the tenant\n    # cluster name via ResolveOrMint. Keep in sync with metadata.yaml `version`.\n    dagweave.io/catalog-version: \"1.0.0\"\n    dagweave.io/catalog-category: \"Databases\"\nspec:\n  entrypoint: query\n  templates:\n    - name: query\n      inputs:\n        parameters:\n          # The SQL query to run.\n          - name: query\n          # PostgreSQL server host.\n          - name: host\n          # PostgreSQL server port.\n          - name: port\n            default: \"5432\"\n          # Database name to connect to.\n          - name: database\n          # User to authenticate as.\n          - name: user\n          # Name of the Kubernetes Secret holding the user's password. Defaults let a\n          # user leave them blank in the Inspector.\n          - name: password-secret-name\n            default: postgres-password\n          - name: password-secret-key\n            default: password\n      container:\n        # Pinned by digest per the catalog convention: an image rebuild can never\n        # silently change the behaviour of an already-released item version.\n        # postgres:19-alpine\n        image: postgres@sha256:8b0ff4cdf221f0c53d7fcda681d3b461be725c492cd881c5ec9c0ad25023f188\n        command: [sh, -c]\n        # The connection values and the query are passed as env vars (below), never\n        # interpolated into the shell, so a query containing quotes or shell\n        # metacharacters is safe. psql reads PGHOST/PGPORT/PGDATABASE/PGUSER/PGPASSWORD\n        # from the environment. ON_ERROR_STOP makes a bad query fail the step.\n        args:\n          - |\n            set -eu\n            psql -v ON_ERROR_STOP=1 -c \"$QUERY\"\n        env:\n          - name: PGHOST\n            value: \"{{inputs.parameters.host}}\"\n          - name: PGPORT\n            value: \"{{inputs.parameters.port}}\"\n          - name: PGDATABASE\n            value: \"{{inputs.parameters.database}}\"\n          - name: PGUSER\n            value: \"{{inputs.parameters.user}}\"\n          - name: QUERY\n            value: \"{{inputs.parameters.query}}\"\n          - name: PGPASSWORD\n            valueFrom:\n              secretKeyRef:\n                name: \"{{inputs.parameters.password-secret-name}}\"\n                key: \"{{inputs.parameters.password-secret-key}}\"\n",
  "templateSha256": "c10e75ebc3180354c57921b4de6e9965f579c421f5b245f6ff835c804bc19ee6",
  "source": "https://github.com/dagweave/catalog/tree/67458f74dbbf913b03177f3cefc69424be85eb1d/catalog/postgres-query",
  "catalogSha": "67458f74dbbf913b03177f3cefc69424be85eb1d"
}
