2.41.0 (latest) 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.1 2.29.0 2.28.1 2.26.0 2.25.0 2.24.0 2.23.1 2.22.0 2.21.0 2.20.0 2.19.0 2.18.1 2.17.0 2.16.0 2.15.0 2.14.1 2.13.2 2.12.0 2.11.3 2.10.1 2.9.0 2.8.1 2.7.1 2.6.0 2.5.2 2.4.0 2.3.3 2.2.0 2.1.0 2.0.0 1.7.3 1.6.1 1.5.1 1.4.0 1.3.0 1.2.1 1.1.0 1.0.0 0.34.0

    Table(table_id, instance, mutation_timeout=None, app_profile_id=None)

Representation of a Google Cloud Bigtable Table.

<br />

> [!NOTE]
> **Note:** We don't define any properties on a table other than the name. The only other fields are `column_families` and `granularity`, The `column_families` are not stored locally and `granularity` is an enum with only one value.

<br />

- `create` the table
- `delete` the table
- `list_column_families` in the table

| ## Parameters ||
|---|---|
| **Name** | **Description** |
| `table_id` | `str` The ID of the table. |
| `instance` | `https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.instance.Instance` The instance that owns the table. |
| `app_profile_id` | `str` (Optional) The unique name of the AppProfile. |

## Properties

### name

Table name used in requests.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_table_name\]
:end-before: \[END bigtable_api_table_name\]
:dedent: 4

<br />

> [!NOTE]
> **Note:** This property will not change if `table_id` does not, but the return value is not cached.

`"projects/../instances/../tables/{table_id}"`

<br />

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `str` | The table name. |

## Methods

### append_row

    append_row(row_key)

Create a xref_AppendRow associated with this table.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_table_append_row\]
:end-before: \[END bigtable_api_table_append_row\]
:dedent: 4

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `row_key` | `bytes` The key for the row being created. |

### backup

    backup(backup_id, cluster_id=None, expire_time=None)

Factory to create a Backup linked to this Table.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `backup_id` | `str` The ID of the Backup to be created. |
| `cluster_id` | `str` (Optional) The ID of the Cluster. Required for calling 'delete', 'exists' etc. methods. |
| `expire_time` | `` `datetime.datetime` `` (Optional) The expiration time of this new Backup. Required, if the `create` method needs to be called. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `.Backup` `` | A backup linked to this table. |

### column_family

    column_family(column_family_id, gc_rule=None)

Factory to create a column family associated with this table.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_table_column_family\]
:end-before: \[END bigtable_api_table_column_family\]
:dedent: 4

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `column_family_id` | `str` The ID of the column family. Must be of the form `<code>_a-zA-Z0-9][-_.a-zA-Z0-9]</code>*`. |
| `gc_rule` | `` `.GarbageCollectionRule` `` (Optional) The garbage collection settings for this column family. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `.ColumnFamily` `` | A column family owned by this table. |

### conditional_row

    conditional_row(row_key, filter_)

Create a xref_ConditionalRow associated with this table.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_table_conditional_row\]
:end-before: \[END bigtable_api_table_conditional_row\]
:dedent: 4

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `row_key` | `bytes` The key for the row being created. |
| `filter_` | `` `.RowFilter` `` (Optional) Filter to be used for conditional mutations. See `.ConditionalRow` for more details. |

### create

    create(initial_split_keys=[], column_families={})

Creates this table.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_create_table\]
:end-before: \[END bigtable_api_create_table\]
:dedent: 4

> [!NOTE]
> **Note:** A create request returns a `._generated.table.Table` but we don't use this response.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `initial_split_keys` | `list` (Optional) list of row keys in bytes that will be used to initially split the table into several tablets. |
| `column_families` | `dict` (Optional) A map columns to create. The key is the column_id str and the value is a `GarbageCollectionRule` |

### delete

    delete()

Delete this table.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_delete_table\]
:end-before: \[END bigtable_api_delete_table\]
:dedent: 4

### direct_row

    direct_row(row_key)

Create a xref_DirectRow associated with this table.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_table_direct_row\]
:end-before: \[END bigtable_api_table_direct_row\]
:dedent: 4

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `row_key` | `bytes` The key for the row being created. |

### drop_by_prefix

    drop_by_prefix(row_key_prefix, timeout=None)

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_drop_by_prefix\]
:end-before: \[END bigtable_api_drop_by_prefix\]
:dedent: 4

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `row_key_prefix` | `bytes` Delete all rows that start with this row key prefix. Prefix cannot be zero length. |
| `timeout` | `float` (Optional) The amount of time, in seconds, to wait for the request to complete. :raise: google.api_core.exceptions.GoogleAPICallError: If the request failed for any reason. google.api_core.exceptions.RetryError: If the request failed due to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. |

### exists

    exists()

Check whether the table exists.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_check_table_exists\]
:end-before: \[END bigtable_api_check_table_exists\]
:dedent: 4

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` | True if the table exists, else False. |

### get_cluster_states

    get_cluster_states()

List the cluster states owned by this table.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_get_cluster_states\]
:end-before: \[END bigtable_api_get_cluster_states\]
:dedent: 4

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `dict` | Dictionary of cluster states for this table. Keys are cluster ids and values are :class: 'ClusterState' instances. |

### get_encryption_info

    get_encryption_info()

List the encryption info for each cluster owned by this table.

Gets the current encryption info for the table across all of the clusters. The
returned dict will be keyed by cluster id and contain a status for all of the
keys in use.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `dict` | Dictionary of encryption info for this table. Keys are cluster ids and values are tuples of EncryptionInfo instances. |

### get_iam_policy

    get_iam_policy()

Gets the IAM access control policy for this table.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_table_get_iam_policy\]
:end-before: \[END bigtable_api_table_get_iam_policy\]
:dedent: 4

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Policy` | The current IAM policy of this table. |

### list_backups

    list_backups(cluster_id=None, filter_=None, order_by=None, page_size=0)

List Backups for this Table.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `cluster_id` | `str` (Optional) Specifies a single cluster to list Backups from. If none is specified, the returned list contains all the Backups in this Instance. |
| `filter_` | `str` (Optional) A filter expression that filters backups listed in the response. The expression must specify the field name, a comparison operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The comparison operator must be \<, \>, \<=, \>=, !=, =, or :. Colon ':' represents a HAS operator which is roughly synonymous with equality. Filter rules are case insensitive. The fields eligible for filtering are: - `name` - `source_table` - `state` - `start_time` (values of the format YYYY-MM-DDTHH:MM:SSZ) - `end_time` (values of the format YYYY-MM-DDTHH:MM:SSZ) - `expire_time` (values of the format YYYY-MM-DDTHH:MM:SSZ) - `size_bytes` To filter on multiple expressions, provide each separate expression within parentheses. By default, each expression is an AND expression. However, you can include AND, OR, and NOT expressions explicitly. Some examples of using filters are: - `name:"exact"` --\> The Backup name is the string "exact". - `name:howl` --\> The Backup name contains the string "howl" - `source_table:prod` --\> The source table's name contains the string "prod". - `state:CREATING` --\> The Backup is pending creation. - `state:READY` --\> The Backup is created and ready for use. - `(name:howl) AND (start_time < "2020-05-28T14:50:00Z")` --\> The Backup name contains the string "howl" and the Backup start time is before 2020-05-28T14:50:00Z. - `size_bytes > 10000000000` --\> The Backup size is greater than 10GB |
| `order_by` | `str` (Optional) An expression for specifying the sort order of the results of the request. The string value should specify one or more fields in `Backup`. The full syntax is described at <https://aip.dev/132#ordering>. Fields supported are: \* name \* source_table \* expire_time \* start_time \* end_time \* size_bytes \* state For example, "start_time". The default sorting order is ascending. To specify descending order for the field, a suffix " desc" should be appended to the field name. For example, "start_time desc". Redundant space characters in the syntax are insigificant. If order_by is empty, results will be sorted by `start_time` in descending order starting from the most recently created backup. |
| `page_size` | `int` (Optional) The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `` `ValueErro `` |   |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `google.api_core.page_iterator.Iterator` `` | Iterator of [Backup](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.backup.Backup) resources within the current Instance. |

### list_column_families

    list_column_families()

List the column families owned by this table.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_list_column_families\]
:end-before: \[END bigtable_api_list_column_families\]
:dedent: 4

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `` `ValueErro `` |   |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `dict` | Dictionary of column families attached to this table. Keys are strings (column family names) and values are `.ColumnFamily` instances. |

### mutate_rows

    mutate_rows(
        rows,
        retry=google.api_core.retry.retry_unary.Retry,
        timeout=_MethodDefault._DEFAULT_VALUE,
    )

Mutates multiple rows in bulk.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_mutate_rows\]
:end-before: \[END bigtable_api_mutate_rows\]
:dedent: 4

The method tries to update all specified rows.
If some of the rows weren't updated, it would not remove mutations.
They can be applied to the row separately.
If row mutations finished successfully, they would be cleaned up.

Optionally, a `retry` strategy can be specified to re-attempt
mutations on rows that return transient errors. This method will retry
until all rows succeed or until the request deadline is reached. To
specify a `retry` strategy of "do-nothing", a deadline of `0.0`
can be specified.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `rows` | `list` List or other iterable of `.DirectRow` instances. |
| `retry` | `` `google.api_core.retry.Retry` `` (Optional) Retry delay and deadline arguments. To override, the default value `DEFAULT_RETRY` can be used and modified with the `google.api_core.retry.Retry.with_delay` method or the `google.api_core.retry.Retry.with_deadline` method. |
| `timeout` | `float` number of seconds bounding retries for the call |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `list` | A list of response statuses (`google.rpc.status_pb2.Status`) corresponding to success or failure of each row mutation sent. These will be in the same order as the `rows`. |

### mutations_batcher

    mutations_batcher(flush_count=100, max_row_bytes=20971520)

Factory to create a mutation batcher associated with this instance.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_mutations_batcher\]
:end-before: \[END bigtable_api_mutations_batcher\]
:dedent: 4

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `flush_count` | `int` (Optional) Maximum number of rows per batch. If it reaches the max number of rows it calls finish_batch() to mutate the current row batch. Default is FLUSH_COUNT (1000 rows). |
| `max_row_bytes` | `int` (Optional) Max number of row mutations size to flush. If it reaches the max number of row mutations size it calls finish_batch() to mutate the current row batch. Default is MAX_ROW_BYTES (5 MB). |

### read_row

    read_row(row_key, filter_=None, retry=google.api_core.retry.retry_unary.Retry)

Read a single row from this table.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_read_row\]
:end-before: \[END bigtable_api_read_row\]
:dedent: 4

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `row_key` | `bytes` The key of the row to read from. |
| `filter_` | `` `.RowFilter` `` (Optional) The filter to apply to the contents of the row. If unset, returns the entire row. |
| `retry` | `` `google.api_core.retry.Retry` `` (Optional) Retry delay and deadline arguments. To override, the default value `DEFAULT_RETRY_READ_ROWS` can be used and modified with the `google.api_core.retry.Retry.with_delay` method or the `google.api_core.retry.Retry.with_deadline` method. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `` `ValueErro `` |   |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `.PartialRowData`, :data:`NoneType ` `` | The contents of the row if any chunks were returned in the response, otherwise :data:`None`. |

### read_rows

    read_rows(
        start_key=None,
        end_key=None,
        limit=None,
        filter_=None,
        end_inclusive=False,
        row_set=None,
        retry=google.api_core.retry.retry_unary.Retry,
    )

Read rows from this table.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_read_rows\]
:end-before: \[END bigtable_api_read_rows\]
:dedent: 4

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `start_key` | `bytes` (Optional) The beginning of a range of row keys to read from. The range will include `start_key`. If left empty, will be interpreted as the empty string. |
| `end_key` | `bytes` (Optional) The end of a range of row keys to read from. The range will not include `end_key`. If left empty, will be interpreted as an infinite string. |
| `limit` | `int` (Optional) The read will terminate after committing to N rows' worth of results. The default (zero) is to return all results. |
| `filter_` | `` `.RowFilter` `` (Optional) The filter to apply to the contents of the specified row(s). If unset, reads every column in each row. |
| `end_inclusive` | `bool` (Optional) Whether the `end_key` should be considered inclusive. The default is False (exclusive). |
| `row_set` | `` `.RowSet` `` (Optional) The row set containing multiple row keys and row_ranges. |
| `retry` | `` `google.api_core.retry.Retry` `` (Optional) Retry delay and deadline arguments. To override, the default value `DEFAULT_RETRY_READ_ROWS` can be used and modified with the `google.api_core.retry.Retry.with_delay` method or the `google.api_core.retry.Retry.with_deadline` method. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `.PartialRowsData` `` | A `.PartialRowsData` a generator for consuming the streamed results. |

### restore

    restore(new_table_id, cluster_id=None, backup_id=None, backup_name=None)

Creates a new Table by restoring from the Backup specified by either
`backup_id` or `backup_name`. The returned `long-running operation`
can be used to track the progress of the operation and to cancel it.
The `response` type is `Table`, if successful.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `new_table_id` | `str` The ID of the Table to create and restore to. This Table must not already exist. |
| `cluster_id` | `str` The ID of the Cluster containing the Backup. This parameter gets overriden by `backup_name`, if the latter is provided. |
| `backup_id` | `str` The ID of the Backup to restore the Table from. This parameter gets overriden by `backup_name`, if the latter is provided. |
| `backup_name` | `str` (Optional) The full name of the Backup to restore from. If specified, it overrides the `cluster_id` and `backup_id` parameters even of such specified. :return: An instance of `google.api_core.operation.Operation`. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `google.api_core.exceptions.AlreadyExists` | If the table already exists. |
| `google.api_core.exceptions.GoogleAPICallError` | If the request failed for any reason. |
| `google.api_core.exceptions.RetryError` | If the request failed due to a retryable error and retry attempts failed. |
| `ValueError` | If the parameters are invalid. |

### row

    row(row_key, filter_=None, append=False)

Factory to create a row associated with this table.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_table_row\]
:end-before: \[END bigtable_api_table_row\]
:dedent: 4

> [!WARNING]
> **Warning:** At most one of `filter_` and `append` can be used in a xref_Row.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `row_key` | `bytes` The key for the row being created. |
| `filter_` | `` `.RowFilter` `` (Optional) Filter to be used for conditional mutations. See `.ConditionalRow` for more details. |
| `append` | `bool` (Optional) Flag to determine if the row should be used for append mutations. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `` `ValueErro `` |   |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.row.Row` | A row owned by this table. |

### sample_row_keys

    sample_row_keys()

Read a sample of row keys in the table.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_sample_row_keys\]
:end-before: \[END bigtable_api_sample_row_keys\]
:dedent: 4

The returned row keys will delimit contiguous sections of the table of
approximately equal size, which can be used to break up the data for
distributed tasks like mapreduces.

The elements in the iterator are a SampleRowKeys response and they have
the properties `offset_bytes` and `row_key`. They occur in sorted
order. The table might have contents before the first row key in the
list and after the last one, but a key containing the empty string
indicates "end of table" and will be the last response given, if
present.

> [!NOTE]
> **Note:** Row keys in this list may not have ever been written to or read from, and users should therefore not make any assumptions about the row key structure that are specific to their use case.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `GrpcRendezvous` | A cancel-able iterator. Can be consumed by calling `next()` or by casting to a `list` and can be cancelled by calling `cancel()`. |

### set_iam_policy

    set_iam_policy(policy)

Sets the IAM access control policy for this table. Replaces any
existing policy.

For more information about policy, please see documentation of
class `google.cloud.bigtable.policy.Policy`

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_table_set_iam_policy\]
:end-before: \[END bigtable_api_table_set_iam_policy\]
:dedent: 4

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `policy` | `Policy` A new IAM policy to replace the current IAM policy of this table. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Policy` | The current IAM policy of this table. |

### test_iam_permissions

    test_iam_permissions(permissions)

Tests whether the caller has the given permissions for this table.
Returns the permissions that the caller has.

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_table_test_iam_permissions\]
:end-before: \[END bigtable_api_table_test_iam_permissions\]
:dedent: 4

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `permissions` | `list` The set of permissions to check for the `resource`. Permissions with wildcards (such as '*' or 'storage.* ') are not allowed. For more information see `IAM Overview https://cloud.google.com/iam/docs/overview#permissions`*. `Bigtable Permissions https://cloud.google.com/bigtable/docs/access-control`*. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `list` | A List(string) of permissions allowed on the table. |

### truncate

    truncate(timeout=None)

Truncate the table

For example:

.. literalinclude:: snippets_table.py
:start-after: \[START bigtable_api_truncate_table\]
:end-before: \[END bigtable_api_truncate_table\]
:dedent: 4

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `timeout` | `float` (Optional) The amount of time, in seconds, to wait for the request to complete. :raise: google.api_core.exceptions.GoogleAPICallError: If the request failed for any reason. google.api_core.exceptions.RetryError: If the request failed due to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. |

### yield_rows

    yield_rows(**kwargs)

Read rows from this table.

> [!WARNING]
> **Warning:** This method will be removed in future releases. Please use `read_rows` instead.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `start_key` | `bytes` (Optional) The beginning of a range of row keys to read from. The range will include `start_key`. If left empty, will be interpreted as the empty string. |
| `end_key` | `bytes` (Optional) The end of a range of row keys to read from. The range will not include `end_key`. If left empty, will be interpreted as an infinite string. |
| `limit` | `int` (Optional) The read will terminate after committing to N rows' worth of results. The default (zero) is to return all results. |
| `filter_` | `` `.RowFilter` `` (Optional) The filter to apply to the contents of the specified row(s). If unset, reads every column in each row. |
| `row_set` | `` `.RowSet` `` (Optional) The row set containing multiple row keys and row_ranges. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `` `.PartialRowData` `` | A `.PartialRowData` for each row returned |