> ## Documentation Index
> Fetch the complete documentation index at: https://deepline.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Customer Db README: Inputs, Cost & CLI Example

> Running SQL against the tenant customer DB and returning structured rows. Includes inputs, outputs, costs, and Deepline CLI examples for GTM automation.

## Run in Enrichment Spreadsheet

<Info>
  Use this function as a column step in `deepline enrich`.
</Info>

```bash theme={null}
deepline enrich --input leads.csv --output leads.enriched.csv --with 'result=customer_db_query_customer_db:{"sql":"{{sql}}"}' --json
```

<Tip>
  Map payload values to spreadsheet columns with `{{column_name}}` placeholders.
</Tip>

## Input Schema

| Name               | Type      | Required | Default | Description                                                                                                                                                                                                                                                                                                                                               |
| ------------------ | --------- | -------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `payload.sql`      | `string`  | Yes      |         | One SQL statement for the workspace customer DB. Use SELECT/EXPLAIN/read-only WITH to inspect permitted schemas. Writes and DDL must target a schema-qualified customer-managed table or schema, for example CREATE TABLE analytics.agent\_notes (...). Protected Deepline schemas are read-only, and unqualified CREATE TABLE blocked (...) is rejected. |
| `payload.max_rows` | `integer` | No       |         | Maximum rows to return in the response payload. Default 1000. This caps returned rows only; it does not restrict SQL shape, aggregates, GROUP BY, or CTE usage.                                                                                                                                                                                           |

<details>
  <summary>Show raw input schema</summary>

  ### Input JSON Schema

  ```json theme={null}
  {
    "type": "object",
    "description": "Query the workspace customer database through Deepline APIs and return structured rows. This is the agent-safe SQL surface: read permitted schemas, but write only schema-qualified customer-managed targets outside protected Deepline schemas. CREATE TABLE, INSERT, UPDATE, DELETE, ALTER, DROP, TRUNCATE, and CREATE INDEX require schema-qualified targets.",
    "properties": {
      "sql": {
        "type": "string",
        "description": "One SQL statement for the workspace customer DB. Use SELECT/EXPLAIN/read-only WITH to inspect permitted schemas. Writes and DDL must target a schema-qualified customer-managed table or schema, for example CREATE TABLE analytics.agent_notes (...). Protected Deepline schemas are read-only, and unqualified CREATE TABLE blocked (...) is rejected.",
        "minLength": 1
      },
      "max_rows": {
        "type": "integer",
        "description": "Maximum rows to return in the response payload. Default 1000. This caps returned rows only; it does not restrict SQL shape, aggregates, GROUP BY, or CTE usage.",
        "minimum": 1,
        "maximum": 1000
      }
    },
    "required": [
      "sql"
    ],
    "additionalProperties": false
  }
  ```
</details>

## Output Schema

| Name                        | Type      | Required | Default | Description |
| --------------------------- | --------- | -------- | ------- | ----------- |
| `result.command`            | `string`  | Yes      |         |             |
| `result.row_count`          | `integer` | Yes      |         |             |
| `result.row_count_returned` | `integer` | Yes      |         |             |
| `result.truncated`          | `boolean` | Yes      |         |             |
| `result.columns`            | `array`   | Yes      |         |             |
| `result.rows`               | `array`   | Yes      |         |             |
| `result.dataset`            | `object`  | No       |         |             |

<details>
  <summary>Show raw output schema</summary>

  ### Output JSON Schema

  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "command": {
        "type": "string"
      },
      "row_count": {
        "type": [
          "integer",
          "null"
        ]
      },
      "row_count_returned": {
        "type": "integer"
      },
      "truncated": {
        "type": "boolean"
      },
      "columns": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "table_id": {
              "type": [
                "integer",
                "null"
              ]
            },
            "data_type_id": {
              "type": [
                "integer",
                "null"
              ]
            }
          },
          "required": [
            "name",
            "table_id",
            "data_type_id"
          ],
          "additionalProperties": false
        }
      },
      "rows": {
        "type": "array",
        "items": {
          "type": "object",
          "additionalProperties": {}
        }
      },
      "dataset": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "customer_db_query"
            ]
          },
          "total_rows": {
            "type": "integer"
          },
          "returned_limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          },
          "page_size": {
            "type": "integer"
          }
        },
        "required": [
          "kind",
          "total_rows",
          "returned_limit",
          "offset",
          "page_size"
        ],
        "additionalProperties": false
      }
    },
    "required": [
      "command",
      "row_count",
      "row_count_returned",
      "truncated",
      "columns",
      "rows"
    ],
    "additionalProperties": false
  }
  ```
</details>

## Advanced: Direct CLI

<Info>
  Use direct execution for single payload debugging.
</Info>

```bash theme={null}
deepline tools execute customer_db_query_customer_db --payload '{
  "sql": "string"
}' --json
```

### CLI flags

| Flag                        | Description                                         |
| --------------------------- | --------------------------------------------------- |
| `--json`                    | Print machine-readable output.                      |
| `--wait`                    | Wait for terminal provider status when supported.   |
| `--debug`                   | Enable wait mode with additional status/log output. |
| `--wait-timeout SECONDS`    | Max seconds to wait in wait mode.                   |
| `--poll-interval SECONDS`   | Polling interval in seconds during wait mode.       |
| `--timeout SECONDS`         | Request timeout in seconds.                         |
| `--connect-timeout SECONDS` | Connection timeout in seconds.                      |

## Cost

* Pricing model: `fixed` (per call).
* Estimated Deepline credits: `0` per pricing unit.
* Provider-native pricing may still exist outside Deepline credit billing.
* Billing mode: `no_bill`.
