# Insert Row — PostgreSQL

> Adds a new row. See the documentation

- Key: `postgresql-insert-row`
- Type: Action (Write)
- Version: 2.0.9
- App: PostgreSQL (`postgresql`) — https://pipedream.com/apps/postgresql.md
- This page (HTML): https://pipedream.com/apps/postgresql/actions/insert-row
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/postgresql/actions/insert-row/insert-row.mjs

## Description

Adds a new row. [See the documentation](https://node-postgres.com/features/queries)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `schema` | `string` | Yes | Database schema Options are loaded from the connected account. |
| `table` | `string` | Yes | Database table Options are loaded from the connected account. |
| `rowValues` | `object` | Yes | JSON representation of your table rows. Accept a single row (JSON Object) or multiple rows (JSON array). For example: { "product_id": 1, "product_name": "Laptop Pro 15", "price": 1200.50, "stock_quantity": 50, "created_at": "2023-10-26T10:00:00Z" } |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "postgresql",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "postgresql-insert-row",
  arguments: {
    schema: "Schema",
    table: "Table",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "postgresql-insert-row",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    postgresql: { authProvisionId: "apn_xxxxxxx" },
    schema: "Schema",
    table: "Table",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "postgresql-insert-row",
    "configured_props": {
      "postgresql": { "authProvisionId": "apn_xxxxxxx" },
      "schema": "Schema",
      "table": "Table"
    }
  }'
```

---

- App: https://pipedream.com/apps/postgresql.md · All apps: https://pipedream.com/apps
