# Class Connection (3.7.0-rc)

3.7.0-rc 3.6.0 (latest) 3.5.0 3.4.0 3.3.0 3.2.0 2.48.0-rc 2.47.1 2.46.0 2.45.0 2.44.0 2.43.0 2.42.0 2.41.0 2.40.0 2.39.0 2.38.0 2.37.0 2.36.0 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.29.0 2.28.0 2.27.0 2.26.0 2.25.1 2.24.0 2.23.0 2.22.1 2.21.0 2.20.0 2.19.0 2.18.0 2.17.0 2.16.0 2.15.1 2.14.0 2.13.0 2.12.0 2.11.0 A connection to a Spanner database instance.
This interface defines pure-virtual methods for each of the user-facing overload sets in [`Client`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client). That is, all of [`Client`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client)'s [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Connection#classgoogle_1_1cloud_1_1spanner_1_1Connection_1a36275e0fd1b201137a8f54e2f7e64cb5) overloads will forward to the one pure-virtual [`Read()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Connection#classgoogle_1_1cloud_1_1spanner_1_1Connection_1a36275e0fd1b201137a8f54e2f7e64cb5) method declared in this interface, and similar for [`Client`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client)'s other methods. This allows users to inject custom behavior (e.g., with a Google Mock object) in a [`Client`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client) object for use in their own tests.

To create a concrete instance that connects you to a real Spanner database, see [`MakeConnection()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/namespacegoogle_1_1cloud_1_1spanner).

## Functions

### virtual options()

Returns the options used by the [Connection](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Connection).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Options` |   |

### virtual Read(ReadParams)

Defines the interface for [`Client::Read()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a167955c44cd3ccb46ffe07cad6e7e52b)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `ReadParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `RowStream` |   |

### virtual PartitionRead(PartitionReadParams)

Defines the interface for [`Client::PartitionRead()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a039dd1aa3b34ad3cbeda17d810809b17)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `PartitionReadParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< std::vector< ReadPartition > >` |   |

### virtual ExecuteQuery(SqlParams)

Defines the interface for [`Client::ExecuteQuery()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a8e2afee42f535c0436d9161c54b84179)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `SqlParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `RowStream` |   |

### virtual ExecuteDml(SqlParams)

Defines the interface for [`Client::ExecuteDml()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1aec1b7d1cd45111126af5aa3b69c8eed0)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `SqlParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< DmlResult >` |   |

### virtual ProfileQuery(SqlParams)

Defines the interface for [`Client::ProfileQuery()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1abee0a6c093b2d7a645f899368b082eae)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `SqlParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ProfileQueryResult` |   |

### virtual ProfileDml(SqlParams)

Defines the interface for [`Client::ProfileDml()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a5628f7c60f46d6d49408245cd9fe8fc1)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `SqlParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< ProfileDmlResult >` |   |

### virtual AnalyzeSql(SqlParams)

Defines the interface for [`Client::AnalyzeSql()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1ad90737b8234c7ead6bc4e8273108f152)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `SqlParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< ExecutionPlan >` |   |

### virtual ExecutePartitionedDml(ExecutePartitionedDmlParams)

Defines the interface for [`Client::ExecutePartitionedDml()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a0cbf8aebf8e345ec3acf0479c8674635)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `ExecutePartitionedDmlParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< PartitionedDmlResult >` |   |

### virtual PartitionQuery(PartitionQueryParams)

Defines the interface for [`Client::PartitionQuery()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a4b99fa616d2f417c64621523b06a58cf)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `PartitionQueryParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< std::vector< QueryPartition > >` |   |

### virtual ExecuteBatchDml(ExecuteBatchDmlParams)

Defines the interface for [`Client::ExecuteBatchDml()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a23079113b30a48efba6f9ab200e48752)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `ExecuteBatchDmlParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< BatchDmlResult >` |   |

### virtual Commit(CommitParams)

Defines the interface for [`Client::Commit()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1ae83521aef8045ac04b0a5dc85b08a2d9)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `CommitParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< CommitResult >` |   |

### virtual Rollback(RollbackParams)

Defines the interface for [`Client::Rollback()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a2687b25e5090ae63e9521c93903a94a3)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `RollbackParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Status` |   |

### virtual BatchWrite(BatchWriteParams)

Defines the interface for batched [`Client::CommitAtLeastOnce()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a3765eebf4b408b580d7d3ef9d7f52ed2)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `BatchWriteParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `BatchedCommitResultStream` |   |