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 User-friendly container for Google Cloud Bigtable Table.

### *class* google.cloud.bigtable.table.ClusterState(replication_state)

Bases: [`object`](https://docs.python.org/3/library/functions.html#object)

Representation of a Cluster State.

- **Parameters**

  **replication_state** ([*int*](https://docs.python.org/3/library/functions.html#int)) -- enum value for cluster state
  Possible replications_state values are
  0 for STATE_NOT_KNOWN: The replication state of the table is
  unknown in this cluster.
  1 for INITIALIZING: The cluster was recently created, and the
  table must finish copying
  over pre-existing data from other clusters before it can
  begin receiving live replication updates and serving
  `Data API` requests.
  2 for PLANNED_MAINTENANCE: The table is temporarily unable to
  serve
  `Data API` requests from this
  cluster due to planned internal maintenance.
  3 for UNPLANNED_MAINTENANCE: The table is temporarily unable
  to serve
  `Data API` requests from this
  cluster due to unplanned or emergency maintenance.
  4 for READY: The table can serve
  `Data API` requests from this
  cluster. Depending on replication delay, reads may not
  immediately reflect the state of the table in other clusters.

#### _*eq_*(other)

Checks if two ClusterState instances(self and other) are
equal on the basis of instance variable 'replication_state'.

- **Parameters**

  **other** (*ClusterState*) -- ClusterState instance to compare with.
- **Return type**

  Boolean value
- **Returns**

  True if two cluster state instances have same
  replication_state.

#### _*ne_*(other)

Checks if two ClusterState instances(self and other) are
not equal.

- **Parameters**

  **other** (*ClusterState.*) -- ClusterState instance to compare with.
- **Return type**

  Boolean value.
- **Returns**

  True if two cluster state instances are not equal.

#### _*repr_*()

Representation of cluster state instance as string value
for cluster state.

- **Return type**

  ClusterState instance
- **Returns**

  ClusterState instance as representation of string
  value for cluster state.

### google.cloud.bigtable.table.DEFAULT_RETRY(*= \<google.api_core.retry.retry_unary.Retry object* )

The default retry strategy to be used on retry-able errors.

Used by `mutate_rows()`.

### google.cloud.bigtable.table.RETRYABLE_MUTATION_ERRORS(*= (\<class 'google.api_core.exceptions.Aborted'\>, \<class 'google.api_core.exceptions.DeadlineExceeded'\>, \<class 'google.api_core.exceptions.ServiceUnavailable'\>, \<class 'google.api_core.exceptions.InternalServerError'\>* )

Errors which can be retried during row mutation.

### *class* google.cloud.bigtable.table.Table(table_id, instance, mutation_timeout=None, app_profile_id=None)

Bases: [`object`](https://docs.python.org/3/library/functions.html#object)

Representation of a Google Cloud Bigtable Table.

**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.

We can use a `Table` to:

- `create()` the table

- `delete()` the table

- `list_column_families()` in the table

- **Parameters**

  - **table_id** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- The ID of the table.

  - **instance** ([`Instance`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/instance#google.cloud.bigtable.instance.Instance)) -- The instance that owns the table.

  - **app_profile_id** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- (Optional) The unique name of the AppProfile.

#### append_row(row_key)

Create a [`AppendRow`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row#google.cloud.bigtable.row.AppendRow) associated with this table.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table(TABLE_ID)

    row_keys = [b"row_key_1", b"row_key_2"]
    row1_obj = table.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.table.Table.html#google_cloud_bigtable_table_Table_append_row(row_keys[0])
    row2_obj = table.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.table.Table.html#google_cloud_bigtable_table_Table_append_row(row_keys[1])

- **Parameters**

  **row_key** ([*bytes*](https://docs.python.org/3/library/stdtypes.html#bytes)) -- The key for the row being created.
- **Returns**

  A row owned by this table.

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

Factory to create a Backup linked to this Table.

- **Parameters**

  - **backup_id** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- The ID of the Backup to be created.

  - **cluster_id** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- (Optional) The ID of the Cluster. Required for
    calling 'delete', 'exists' etc. methods.

  - **expire_time** ([`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime)) -- (Optional) The expiration time of this new Backup.
    Required, if the create method needs to be called.

- **Return type**

  [`Backup`](https://docs.cloud.google.com/python/docs/reference/bigtable/admin_client/types_.md#google.cloud.bigtable_admin_v2.types.Backup)
- **Returns**

  A backup linked to this table.

#### column_family(column_family_id, gc_rule=None)

Factory to create a column family associated with this table.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)

    table = instance.table(TABLE_ID)
    column_family_obj = table.column_family(COLUMN_FAMILY_ID)

- **Parameters**

  - **column_family_id** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- The ID of the column family. Must be of the
    form `[_a-zA-Z0-9][-_.a-zA-Z0-9]\*`.

  - **gc_rule** ([`GarbageCollectionRule`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/column-family#google.cloud.bigtable.column_family.GarbageCollectionRule)) -- (Optional) The garbage collection settings for this
    column family.

- **Return type**

  [`ColumnFamily`](https://docs.cloud.google.com/python/docs/reference/bigtable/admin_client/types_.md#google.cloud.bigtable_admin_v2.types.ColumnFamily)
- **Returns**

  A column family owned by this table.

#### conditional_row(row_key, filter_)

Create a [`ConditionalRow`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row#google.cloud.bigtable.row.ConditionalRow) associated with this table.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html
    from google.cloud.bigtable.row_filters import PassAllFilter

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table(TABLE_ID)

    row_keys = [b"row_key_1", b"row_key_2"]
    filter_ = PassAllFilter(True)
    row1_obj = table.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.table.Table.html#google_cloud_bigtable_table_Table_conditional_row(row_keys[0], filter_=filter_)
    row2_obj = table.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.table.Table.html#google_cloud_bigtable_table_Table_conditional_row(row_keys[1], filter_=filter_)

- **Parameters**

  - **row_key** ([*bytes*](https://docs.python.org/3/library/stdtypes.html#bytes)) -- The key for the row being created.

  - **filter** ([`RowFilter`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row-filters#google.cloud.bigtable.row_filters.RowFilter)) -- (Optional) Filter to be used for
    conditional mutations. See [`ConditionalRow`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row#google.cloud.bigtable.row.ConditionalRow) for more details.

- **Returns**

  A row owned by this table.

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

Creates this table.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html, column_family

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)

    # Create table without Column families.
    table1 = instance.table("table_id1")
    table1.create()

    # Create table with Column families.
    table2 = instance.table("table_id2")
    # Define the GC policy to retain only the most recent 2 versions.
    max_versions_rule = column_family.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.column_family.MaxVersionsGCRule.html(2)
    table2.create(column_families={"cf1": max_versions_rule})

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

- **Parameters**

  - **initial_split_keys** ([*list*](https://docs.python.org/3/library/stdtypes.html#list)) -- (Optional) list of row keys in bytes that
    will be used to initially split the table
    into several tablets.

  - **column_families** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict)) -- (Optional) A map columns to create. The key is
    the column_id str and the value is a
    `GarbageCollectionRule`

#### delete()

Delete this table.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table("table_id_del")

    table.delete()

#### direct_row(row_key)

Create a [`DirectRow`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row#google.cloud.bigtable.row.DirectRow) associated with this table.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table(TABLE_ID)

    row_keys = [b"row_key_1", b"row_key_2"]
    row1_obj = table.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.table.Table.html#google_cloud_bigtable_table_Table_direct_row(row_keys[0])
    row2_obj = table.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.table.Table.html#google_cloud_bigtable_table_Table_direct_row(row_keys[1])

- **Parameters**

  **row_key** ([*bytes*](https://docs.python.org/3/library/stdtypes.html#bytes)) -- The key for the row being created.
- **Returns**

  A row owned by this table.

#### drop_by_prefix(row_key_prefix, timeout=None)

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table(TABLE_ID)
    row_key_prefix = b"row_key_2"
    table.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.table.Table.html#google_cloud_bigtable_table_Table_drop_by_prefix(row_key_prefix, timeout=200)

- **Parameters**

  - **row_key_prefix** ([*bytes*](https://docs.python.org/3/library/stdtypes.html#bytes)) -- Delete all rows that start with this row key
    prefix. Prefix cannot be zero length.

  - **timeout** ([*float*](https://docs.python.org/3/library/functions.html#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()

Check whether the table exists.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table(TABLE_ID)
    table_exists = table.exists()

- **Return type**

  [bool](https://docs.python.org/3/library/functions.html#bool)
- **Returns**

  True if the table exists, else False.

#### get_cluster_states()

List the cluster states owned by this table.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table(TABLE_ID)

    get_cluster_states = table.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.table.Table.html#google_cloud_bigtable_table_Table_get_cluster_states()

- **Return type**

  [dict](https://docs.python.org/3/library/stdtypes.html#dict)
- **Returns**

  Dictionary of cluster states for this table.
  Keys are cluster ids and values are
  :class: 'ClusterState' instances.

#### 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.

- **Return type**

  [dict](https://docs.python.org/3/library/stdtypes.html#dict)
- **Returns**

  Dictionary of encryption info for this table. Keys are cluster ids and
  values are tuples of `google.cloud.bigtable.encryption.EncryptionInfo` instances.

#### get_iam_policy()

Gets the IAM access control policy for this table.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table("table_id_iam_policy")
    policy = table.get_iam_policy()

- **Return type**

  `google.cloud.bigtable.policy.Policy`
- **Returns**

  The current IAM policy of this table.

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

List Backups for this Table.

- **Parameters**

  - **cluster_id** ([*str*](https://docs.python.org/3/library/stdtypes.html#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*](https://docs.python.org/3/library/stdtypes.html#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*](https://docs.python.org/3/library/stdtypes.html#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*](https://docs.python.org/3/library/functions.html#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.

- **Return type**

  [`Iterator`](https://googleapis.dev/python/google-api-core/latest/page_iterator.html#google.api_core.page_iterator.Iterator)
- **Returns**

  Iterator of [`Backup`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/backup#google.cloud.bigtable.backup.Backup)
  resources within the current Instance.
- **Raises**

  `ValueError` if one of the
  returned Backups' name is not of the expected format.

#### list_column_families()

List the column families owned by this table.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table(TABLE_ID)

    column_family_list = table.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.table.Table.html#google_cloud_bigtable_table_Table_list_column_families()

- **Return type**

  [dict](https://docs.python.org/3/library/stdtypes.html#dict)
- **Returns**

  Dictionary of column families attached to this table. Keys
  are strings (column family names) and values are
  [`ColumnFamily`](https://docs.cloud.google.com/python/docs/reference/bigtable/admin_client/types_.md#google.cloud.bigtable_admin_v2.types.ColumnFamily) instances.
- **Raises**

  `ValueError` if the column
  family name from the response does not agree with the computed
  name from the column family ID.

#### mutate_rows(rows, retry=\<google.api_core.retry.retry_unary.Retry object\>, timeout=_MethodDefault._DEFAULT_VALUE)

Mutates multiple rows in bulk.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table(TABLE_ID)
    row_keys = [
        b"row_key_1",
        b"row_key_2",
        b"row_key_3",
        b"row_key_4",
        b"row_key_20",
        b"row_key_22",
        b"row_key_200",
    ]
    col_name = b"col-name1"
    rows = []
    for i, row_key in enumerate(row_keys):
        value = "value_{}".format(i).encode()
        row = table.row(row_key)
        row.set_cell(
            COLUMN_FAMILY_ID, col_name, value, timestamp=datetime.now(timezone.utc)
        )
        rows.append(row)
    response = table.mutate_rows(rows)
    # validate that all rows written successfully
    for i, status in enumerate(response):
        if status.code != 0:
            print("Row number {} failed to write".format(i))

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**

  - **rows** ([*list*](https://docs.python.org/3/library/stdtypes.html#list)) -- List or other iterable of [`DirectRow`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row#google.cloud.bigtable.row.DirectRow) instances.

  - **retry** ([`Retry`](https://googleapis.dev/python/google-api-core/latest/retry.html#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 `with_delay()` method or the
    `with_deadline()` method.

  - **timeout** ([*float*](https://docs.python.org/3/library/functions.html#float)) -- number of seconds bounding retries for the call

- **Return type**

  [list](https://docs.python.org/3/library/stdtypes.html#list)
- **Returns**

  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(flush_count=100, max_row_bytes=20971520)

Factory to create a mutation batcher associated with this instance.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table(TABLE_ID)
    batcher = table.mutations_batcher()

- **Parameters**

  - **flush_count** ([*int*](https://docs.python.org/3/library/functions.html#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*](https://docs.python.org/3/library/functions.html#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).

#### *property* name()

Table name used in requests.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)

    table = instance.table(TABLE_ID)
    table_name = table.name

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

The table name is of the form
> `"projects/../instances/../tables/{table_id}"`

- **Return type**

  [str](https://docs.python.org/3/library/stdtypes.html#str)
- **Returns**

  The table name.

#### read_row(row_key, filter_=None, retry=\<google.api_core.retry.retry_unary.Retry object\>)

Read a single row from this table.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table(TABLE_ID)
    row_key = "row_key_1"
    row = table.read_row(row_key)

- **Parameters**

  - **row_key** ([*bytes*](https://docs.python.org/3/library/stdtypes.html#bytes)) -- The key of the row to read from.

  - **filter** ([`RowFilter`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row-filters#google.cloud.bigtable.row_filters.RowFilter)) -- (Optional) The filter to apply to the contents of the
    row. If unset, returns the entire row.

  - **retry** ([`Retry`](https://googleapis.dev/python/google-api-core/latest/retry.html#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 `with_delay()`
    method or the `with_deadline()`
    method.

- **Return type**

  [`PartialRowData`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row#google.cloud.bigtable.row.PartialRowData), `NoneType`
- **Returns**

  The contents of the row if any chunks were returned in
  the response, otherwise [`None`](https://docs.python.org/3/library/constants.html#None).
- **Raises**

  `ValueError` if a commit row
  chunk is never encountered.

#### 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 object\>)

Read rows from this table.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table(TABLE_ID)

    # Read full table
    partial_rows = table.read_rows()

    # Read row's value
    total_rows = []
    for row in partial_rows:
        cell = row.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.row.PartialRowData.html#google_cloud_bigtable_row_PartialRowData_cells[COLUMN_FAMILY_ID][col_name][0]
        print(cell.value.decode("utf-8"))
        total_rows.append(cell)

- **Parameters**

  - **start_key** ([*bytes*](https://docs.python.org/3/library/stdtypes.html#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*](https://docs.python.org/3/library/stdtypes.html#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*](https://docs.python.org/3/library/functions.html#int)) -- (Optional) The read will terminate after committing to N
    rows' worth of results. The default (zero) is to return
    all results.

  - **filter** ([`RowFilter`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row-filters#google.cloud.bigtable.row_filters.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*](https://docs.python.org/3/library/functions.html#bool)) -- (Optional) Whether the `end_key` should be
    considered inclusive. The default is False (exclusive).

  - **row_set** ([`RowSet`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row-set#google.cloud.bigtable.row_set.RowSet)) -- (Optional) The row set containing multiple row keys and
    row_ranges.

  - **retry** ([`Retry`](https://googleapis.dev/python/google-api-core/latest/retry.html#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 `with_delay()`
    method or the `with_deadline()`
    method.

- **Return type**

  [`PartialRowsData`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row-data#google.cloud.bigtable.row_data.PartialRowsData)
- **Returns**

  A [`PartialRowsData`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row-data#google.cloud.bigtable.row_data.PartialRowsData) a generator for consuming
  the streamed results.

#### 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**

  - **new_table_id** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- The ID of the Table to create and restore to.
    This Table must not already exist.

  - **cluster_id** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- The ID of the Cluster containing the Backup.
    This parameter gets overriden by backup_name, if
    the latter is provided.

  - **backup_id** ([*str*](https://docs.python.org/3/library/stdtypes.html#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*](https://docs.python.org/3/library/stdtypes.html#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.

- **Returns**

  An instance of
  [`Operation`](https://googleapis.dev/python/google-api-core/latest/operation.html#google.api_core.operation.Operation).
- **Raises**

  google.api_core.exceptions.AlreadyExists: If the table
  already exists.
- **Raises**

  google.api_core.exceptions.GoogleAPICallError: If the request
  failed for any reason.
- **Raises**

  google.api_core.exceptions.RetryError: If the request failed
  due to a retryable error and retry attempts failed.
- **Raises**

  ValueError: If the parameters are invalid.

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

Factory to create a row associated with this table.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table(TABLE_ID)

    row_keys = [b"row_key_1", b"row_key_2"]
    row1_obj = table.row(row_keys[0])
    row2_obj = table.row(row_keys[1])

**WARNING** : At most one of `filter_` and `append` can be used in a
[`Row`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row#google.cloud.bigtable.row.Row).

- **Parameters**

  - **row_key** ([*bytes*](https://docs.python.org/3/library/stdtypes.html#bytes)) -- The key for the row being created.

  - **filter** ([`RowFilter`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row-filters#google.cloud.bigtable.row_filters.RowFilter)) -- (Optional) Filter to be used for conditional mutations.
    See [`ConditionalRow`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row#google.cloud.bigtable.row.ConditionalRow) for more details.

  - **append** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) -- (Optional) Flag to determine if the row should be used
    for append mutations.

- **Return type**

  [`Row`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row#google.cloud.bigtable.row.Row)
- **Returns**

  A row owned by this table.
- **Raises**

  `ValueError` if both
  `filter_` and `append` are used.

#### sample_row_keys()

Read a sample of row keys in the table.

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)

    table = instance.table("table_id1_samplerow")
    data = table.sample_row_keys()
    actual_keys, offset = zip(*[(rk.row_key, rk.offset_bytes) for rk in data])

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**: 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.

The `offset_bytes` field on a response indicates the approximate
total storage space used by all rows in the table which precede
`row_key`. Buffering the contents of all rows between two subsequent
samples would require space roughly equal to the difference in their
`offset_bytes` fields.

- **Return type**

  `GrpcRendezvous`
- **Returns**

  A cancel-able iterator. Can be consumed by calling `next()`
  or by casting to a [`list`](https://docs.python.org/3/library/stdtypes.html#list) and can be cancelled by
  calling `cancel()`.

#### 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:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html
    from google.cloud.bigtable.policy import BIGTABLE_ADMIN_ROLE, Policy

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table("table_id_iam_policy")
    new_policy = Policy()
    new_policy[BIGTABLE_ADMIN_ROLE] = [Policy.service_account(service_account_email)]

    policy_latest = table.set_iam_policy(new_policy)

- **Parameters**

  **policy** (`google.cloud.bigtable.policy.Policy`) -- A new IAM policy to replace the current IAM policy
  of this table.
- **Return type**

  `google.cloud.bigtable.policy.Policy`
- **Returns**

  The current IAM policy of this table.

#### test_iam_permissions(permissions)

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

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table("table_id_iam_policy")

    permissions = ["bigtable.tables.mutateRows", "bigtable.tables.readRows"]
    permissions_allowed = table.test_iam_permissions(permissions)

- **Parameters**

  **permissions** ([*list*](https://docs.python.org/3/library/stdtypes.html#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).
- **Return type**

  [list](https://docs.python.org/3/library/stdtypes.html#list)
- **Returns**

  A List(string) of permissions allowed on the table.

#### truncate(timeout=None)

Truncate the table

For example:

    from google.cloud.bigtable import https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html

    client = Client(admin=True)
    instance = https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.html.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.client.Client.html#google_cloud_bigtable_client_Client_instance(INSTANCE_ID)
    table = instance.table(TABLE_ID)
    table.https://docs.cloud.google.com/python/docs/reference/bigtable/latest/google.cloud.bigtable.table.Table.html#google_cloud_bigtable_table_Table_truncate(timeout=200)

- **Parameters**

  **timeout** ([*float*](https://docs.python.org/3/library/functions.html#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(\*\*kwargs)

Read rows from this table.

**WARNING** : This method will be removed in future releases. Please use
`read_rows` instead.

- **Parameters**

  - **start_key** ([*bytes*](https://docs.python.org/3/library/stdtypes.html#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*](https://docs.python.org/3/library/stdtypes.html#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*](https://docs.python.org/3/library/functions.html#int)) -- (Optional) The read will terminate after committing to N
    rows' worth of results. The default (zero) is to return
    all results.

  - **filter** ([`RowFilter`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row-filters#google.cloud.bigtable.row_filters.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`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row-set#google.cloud.bigtable.row_set.RowSet)) -- (Optional) The row set containing multiple row keys and
    row_ranges.

- **Return type**

  [`PartialRowData`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row#google.cloud.bigtable.row.PartialRowData)
- **Returns**

  A [`PartialRowData`](https://docs.cloud.google.com/python/docs/reference/bigtable/latest/row#google.cloud.bigtable.row.PartialRowData) for each row returned

### *exception* google.cloud.bigtable.table.TableMismatchError()

Bases: [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)

Row from another table.

### *exception* google.cloud.bigtable.table.TooManyMutationsError()

Bases: [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)

The number of mutations for bulk request is too big.