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

# ports.sql

> `readonly` **sql**: [`AgentHarnessSqlPort`](/docs/agent-sdk/harness-sdk/ports/sql#agentharnesssqlport)

## On the Agent Runtime

[The runtime adapter](/docs/agent-sdk/harness-sdk/adapters/runtime#on-the-agent-runtime) builds the port from `host`, which carries the protected members of the `Agent` class.

```ts theme={null}
// runtime-adapter.ts
sql: Object.freeze({
  exec(query, ...bindings) {
    return host.sql.exec(query, ...bindings);
  },
  transactionSync(fn) {
    return host.transactionSync(fn);
  },
}),
```

* `exec()` calls `exec()` on [`this.ctx.storage.sql`](/docs/agent-sdk/interface/ctx), the instance's own SQLite database. It rejects transaction-control statements such as `BEGIN`.
* `transactionSync()` calls `this.ctx.storage.transactionSync()`. If its function throws, every statement the function ran is rolled back.

## AgentHarnessSqlPort

Synchronous per-actor SQL surface matching ActorStorage exactly.

**Methods**
**exec()**

> **exec**\<`T`>(`query`, ...`bindings`): `SqlCursor`\<`T`>

**Type Parameters**

| Type Parameter | Default type |
| - | - |
|  `T` *extends* `Record`\<`string`, `SqlValue`> | `Record`\<`string`, `SqlValue`> |

**Parameters**

| Parameter | Type |
| - | - |
| `query` | `string` |
| ...`bindings` | `SqlBindValue`\[] |

**Returns**
`SqlCursor`\<`T`>

**transactionSync()**

> **transactionSync**\<`T`>(`fn`): `T`

**Type Parameters**

| Type Parameter |
| - |
|  `T` |

**Parameters**

| Parameter | Type |
| - | - |
| `fn` | () => `T` |

**Returns**
`T`
