Package Classes (3.46.0)

Summary of entries of Classes for spanner.

Classes

DatabaseAdminAsyncClient

Cloud Spanner Database Admin API

The Cloud Spanner Database Admin API can be used to:

  • create, drop, and list databases
  • update the schema of pre-existing databases
  • create, delete and list backups for a database
  • restore a database from an existing backup

DatabaseAdminClient

Cloud Spanner Database Admin API

The Cloud Spanner Database Admin API can be used to:

  • create, drop, and list databases
  • update the schema of pre-existing databases
  • create, delete and list backups for a database
  • restore a database from an existing backup

ListBackupOperationsAsyncPager

A pager for iterating through list_backup_operations requests.

This class thinly wraps an initial ListBackupOperationsResponse object, and provides an __aiter__ method to iterate through its operations field.

If there are more pages, the __aiter__ method will make additional ListBackupOperations requests and continue to iterate through the operations field on the corresponding responses.

All the usual ListBackupOperationsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListBackupOperationsPager

A pager for iterating through list_backup_operations requests.

This class thinly wraps an initial ListBackupOperationsResponse object, and provides an __iter__ method to iterate through its operations field.

If there are more pages, the __iter__ method will make additional ListBackupOperations requests and continue to iterate through the operations field on the corresponding responses.

All the usual ListBackupOperationsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListBackupsAsyncPager

A pager for iterating through list_backups requests.

This class thinly wraps an initial ListBackupsResponse object, and provides an __aiter__ method to iterate through its backups field.

If there are more pages, the __aiter__ method will make additional ListBackups requests and continue to iterate through the backups field on the corresponding responses.

All the usual ListBackupsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListBackupsPager

A pager for iterating through list_backups requests.

This class thinly wraps an initial ListBackupsResponse object, and provides an __iter__ method to iterate through its backups field.

If there are more pages, the __iter__ method will make additional ListBackups requests and continue to iterate through the backups field on the corresponding responses.

All the usual ListBackupsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListDatabaseOperationsAsyncPager

A pager for iterating through list_database_operations requests.

This class thinly wraps an initial ListDatabaseOperationsResponse object, and provides an __aiter__ method to iterate through its operations field.

If there are more pages, the __aiter__ method will make additional ListDatabaseOperations requests and continue to iterate through the operations field on the corresponding responses.

All the usual ListDatabaseOperationsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListDatabaseOperationsPager

A pager for iterating through list_database_operations requests.

This class thinly wraps an initial ListDatabaseOperationsResponse object, and provides an __iter__ method to iterate through its operations field.

If there are more pages, the __iter__ method will make additional ListDatabaseOperations requests and continue to iterate through the operations field on the corresponding responses.

All the usual ListDatabaseOperationsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListDatabaseRolesAsyncPager

A pager for iterating through list_database_roles requests.

This class thinly wraps an initial ListDatabaseRolesResponse object, and provides an __aiter__ method to iterate through its database_roles field.

If there are more pages, the __aiter__ method will make additional ListDatabaseRoles requests and continue to iterate through the database_roles field on the corresponding responses.

All the usual ListDatabaseRolesResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListDatabaseRolesPager

A pager for iterating through list_database_roles requests.

This class thinly wraps an initial ListDatabaseRolesResponse object, and provides an __iter__ method to iterate through its database_roles field.

If there are more pages, the __iter__ method will make additional ListDatabaseRoles requests and continue to iterate through the database_roles field on the corresponding responses.

All the usual ListDatabaseRolesResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListDatabasesAsyncPager

A pager for iterating through list_databases requests.

This class thinly wraps an initial ListDatabasesResponse object, and provides an __aiter__ method to iterate through its databases field.

If there are more pages, the __aiter__ method will make additional ListDatabases requests and continue to iterate through the databases field on the corresponding responses.

All the usual ListDatabasesResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListDatabasesPager

A pager for iterating through list_databases requests.

This class thinly wraps an initial ListDatabasesResponse object, and provides an __iter__ method to iterate through its databases field.

If there are more pages, the __iter__ method will make additional ListDatabases requests and continue to iterate through the databases field on the corresponding responses.

All the usual ListDatabasesResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

Backup

A backup of a Cloud Spanner database.

State

Indicates the current state of the backup.

Enum values:

STATE_UNSPECIFIED (0):
    Not specified.
CREATING (1):
    The pending backup is still being created. Operations on the
    backup may fail with `FAILED_PRECONDITION` in this state.
READY (2):
    The backup is complete and ready for use.

BackupInfo

Information about a backup.

CopyBackupEncryptionConfig

Encryption configuration for the copied backup.

EncryptionType

Encryption types for the backup.

Enum values:

ENCRYPTION_TYPE_UNSPECIFIED (0):
    Unspecified. Do not use.
USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION (1):
    This is the default option for
    `CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup]`
    when
    `encryption_config][google.spanner.admin.database.v1.CopyBackupEncryptionConfig]`
    is not specified. For example, if the source backup is using
    `Customer_Managed_Encryption`, the backup will be using
    the same Cloud KMS key as the source backup.
GOOGLE_DEFAULT_ENCRYPTION (2):
    Use Google default encryption.
CUSTOMER_MANAGED_ENCRYPTION (3):
    Use customer managed encryption. If specified,
    `kms_key_name` must contain a valid Cloud KMS key.

CopyBackupMetadata

Metadata type for the google.longrunning.Operation returned by CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup].

CopyBackupRequest

The request for CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup].

CreateBackupEncryptionConfig

Encryption configuration for the backup to create.

EncryptionType

Encryption types for the backup.

Enum values:

ENCRYPTION_TYPE_UNSPECIFIED (0):
    Unspecified. Do not use.
USE_DATABASE_ENCRYPTION (1):
    Use the same encryption configuration as the database. This
    is the default option when
    `encryption_config][google.spanner.admin.database.v1.CreateBackupEncryptionConfig]`
    is empty. For example, if the database is using
    `Customer_Managed_Encryption`, the backup will be using
    the same Cloud KMS key as the database.
GOOGLE_DEFAULT_ENCRYPTION (2):
    Use Google default encryption.
CUSTOMER_MANAGED_ENCRYPTION (3):
    Use customer managed encryption. If specified,
    `kms_key_name` must contain a valid Cloud KMS key.

CreateBackupMetadata

Metadata type for the operation returned by CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].

CreateBackupRequest

The request for CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].

CreateDatabaseMetadata

Metadata type for the operation returned by CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase].

CreateDatabaseRequest

The request for CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase].

Database

A Cloud Spanner database.

State

Indicates the current state of the database.

Enum values:

STATE_UNSPECIFIED (0):
    Not specified.
CREATING (1):
    The database is still being created. Operations on the
    database may fail with `FAILED_PRECONDITION` in this
    state.
READY (2):
    The database is fully created and ready for
    use.
READY_OPTIMIZING (3):
    The database is fully created and ready for use, but is
    still being optimized for performance and cannot handle full
    load.
    In this state, the database still references the backup it
    was restore from, preventing the backup from being deleted.
    When optimizations are complete, the full performance of the
    database will be restored, and the database will transition
    to `READY` state.

DatabaseDialect

Indicates the dialect type of a database.

Enum values:

DATABASE_DIALECT_UNSPECIFIED (0):
    Default value. This value will create a database with the
    GOOGLE_STANDARD_SQL dialect.
GOOGLE_STANDARD_SQL (1):
    Google standard SQL.
POSTGRESQL (2):
    PostgreSQL supported SQL.

DatabaseRole

A Cloud Spanner database role.

DdlStatementActionInfo

Action information extracted from a DDL statement. This proto is used to display the brief info of the DDL statement for the operation UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl].

DeleteBackupRequest

The request for DeleteBackup][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup].

DropDatabaseRequest

The request for DropDatabase][google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase].

EncryptionConfig

Encryption configuration for a Cloud Spanner database.

EncryptionInfo

Encryption information for a Cloud Spanner database or backup.

Type

Possible encryption types.

Enum values:

TYPE_UNSPECIFIED (0):
    Encryption type was not specified, though
    data at rest remains encrypted.
GOOGLE_DEFAULT_ENCRYPTION (1):
    The data is encrypted at rest with a key that
    is fully managed by Google. No key version or
    status will be populated. This is the default
    state.
CUSTOMER_MANAGED_ENCRYPTION (2):
    The data is encrypted at rest with a key that is managed by
    the customer. The active version of the key.
    `kms_key_version` will be populated, and
    `encryption_status` may be populated.

GetBackupRequest

The request for GetBackup][google.spanner.admin.database.v1.DatabaseAdmin.GetBackup].

GetDatabaseDdlRequest

The request for GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].

GetDatabaseDdlResponse

The response for GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].

GetDatabaseRequest

The request for GetDatabase][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase].

ListBackupOperationsRequest

The request for ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations].

ListBackupOperationsResponse

The response for ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations].

ListBackupsRequest

The request for ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups].

ListBackupsResponse

The response for ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups].

ListDatabaseOperationsRequest

The request for ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].

ListDatabaseOperationsResponse

The response for ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].

ListDatabaseRolesRequest

The request for ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles].

ListDatabaseRolesResponse

The response for ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles].

ListDatabasesRequest

The request for ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].

ListDatabasesResponse

The response for ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].

OperationProgress

Encapsulates progress related information for a Cloud Spanner long running operation.

OptimizeRestoredDatabaseMetadata

Metadata type for the long-running operation used to track the progress of optimizations performed on a newly restored database. This long-running operation is automatically created by the system after the successful completion of a database restore, and cannot be cancelled.

RestoreDatabaseEncryptionConfig

Encryption configuration for the restored database.

EncryptionType

Encryption types for the database to be restored.

Enum values:

ENCRYPTION_TYPE_UNSPECIFIED (0):
    Unspecified. Do not use.
USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION (1):
    This is the default option when
    `encryption_config][google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig]`
    is not specified.
GOOGLE_DEFAULT_ENCRYPTION (2):
    Use Google default encryption.
CUSTOMER_MANAGED_ENCRYPTION (3):
    Use customer managed encryption. If specified,
    `kms_key_name` must must contain a valid Cloud KMS key.

RestoreDatabaseMetadata

Metadata type for the long-running operation returned by RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase].

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

RestoreDatabaseRequest

The request for RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase].

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

RestoreInfo

Information about the database restore.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

RestoreSourceType

Indicates the type of the restore source.

Enum values:

TYPE_UNSPECIFIED (0):
    No restore associated.
BACKUP (1):
    A backup was used as the source of the
    restore.

UpdateBackupRequest

The request for UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup].

UpdateDatabaseDdlMetadata

Metadata type for the operation returned by UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl].

UpdateDatabaseDdlRequest

Enqueues the given DDL statements to be applied, in order but not necessarily all at once, to the database schema at some point (or points) in the future. The server checks that the statements are executable (syntactically valid, name tables that exist, etc.) before enqueueing them, but they may still fail upon later execution (e.g., if a statement from another batch of statements is applied first and it conflicts in some way, or if there is some data-related problem like a NULL value in a column to which NOT NULL would be added). If a statement fails, all subsequent statements in the batch are automatically cancelled.

Each batch of statements is assigned a name which can be used with the Operations][google.longrunning.Operations] API to monitor progress. See the operation_id][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.operation_id] field for more details.

UpdateDatabaseMetadata

Metadata type for the operation returned by UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase].

UpdateDatabaseRequest

The request for UpdateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase].

InstanceAdminAsyncClient

Cloud Spanner Instance Admin API

The Cloud Spanner Instance Admin API can be used to create, delete, modify and list instances. Instances are dedicated Cloud Spanner serving and storage resources to be used by Cloud Spanner databases.

Each instance has a "configuration", which dictates where the serving resources for the Cloud Spanner instance are located (e.g., US-central, Europe). Configurations are created by Google based on resource availability.

Cloud Spanner billing is based on the instances that exist and their sizes. After an instance exists, there are no additional per-database or per-operation charges for use of the instance (though there may be additional network bandwidth charges). Instances offer isolation: problems with databases in one instance will not affect other instances. However, within an instance databases can affect each other. For example, if one database in an instance receives a lot of requests and consumes most of the instance resources, fewer resources are available for other databases in that instance, and their performance may suffer.

InstanceAdminClient

Cloud Spanner Instance Admin API

The Cloud Spanner Instance Admin API can be used to create, delete, modify and list instances. Instances are dedicated Cloud Spanner serving and storage resources to be used by Cloud Spanner databases.

Each instance has a "configuration", which dictates where the serving resources for the Cloud Spanner instance are located (e.g., US-central, Europe). Configurations are created by Google based on resource availability.

Cloud Spanner billing is based on the instances that exist and their sizes. After an instance exists, there are no additional per-database or per-operation charges for use of the instance (though there may be additional network bandwidth charges). Instances offer isolation: problems with databases in one instance will not affect other instances. However, within an instance databases can affect each other. For example, if one database in an instance receives a lot of requests and consumes most of the instance resources, fewer resources are available for other databases in that instance, and their performance may suffer.

ListInstanceConfigOperationsAsyncPager

A pager for iterating through list_instance_config_operations requests.

This class thinly wraps an initial ListInstanceConfigOperationsResponse object, and provides an __aiter__ method to iterate through its operations field.

If there are more pages, the __aiter__ method will make additional ListInstanceConfigOperations requests and continue to iterate through the operations field on the corresponding responses.

All the usual ListInstanceConfigOperationsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListInstanceConfigOperationsPager

A pager for iterating through list_instance_config_operations requests.

This class thinly wraps an initial ListInstanceConfigOperationsResponse object, and provides an __iter__ method to iterate through its operations field.

If there are more pages, the __iter__ method will make additional ListInstanceConfigOperations requests and continue to iterate through the operations field on the corresponding responses.

All the usual ListInstanceConfigOperationsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListInstanceConfigsAsyncPager

A pager for iterating through list_instance_configs requests.

This class thinly wraps an initial ListInstanceConfigsResponse object, and provides an __aiter__ method to iterate through its instance_configs field.

If there are more pages, the __aiter__ method will make additional ListInstanceConfigs requests and continue to iterate through the instance_configs field on the corresponding responses.

All the usual ListInstanceConfigsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListInstanceConfigsPager

A pager for iterating through list_instance_configs requests.

This class thinly wraps an initial ListInstanceConfigsResponse object, and provides an __iter__ method to iterate through its instance_configs field.

If there are more pages, the __iter__ method will make additional ListInstanceConfigs requests and continue to iterate through the instance_configs field on the corresponding responses.

All the usual ListInstanceConfigsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListInstancePartitionOperationsAsyncPager

A pager for iterating through list_instance_partition_operations requests.

This class thinly wraps an initial ListInstancePartitionOperationsResponse object, and provides an __aiter__ method to iterate through its operations field.

If there are more pages, the __aiter__ method will make additional ListInstancePartitionOperations requests and continue to iterate through the operations field on the corresponding responses.

All the usual ListInstancePartitionOperationsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListInstancePartitionOperationsPager

A pager for iterating through list_instance_partition_operations requests.

This class thinly wraps an initial ListInstancePartitionOperationsResponse object, and provides an __iter__ method to iterate through its operations field.

If there are more pages, the __iter__ method will make additional ListInstancePartitionOperations requests and continue to iterate through the operations field on the corresponding responses.

All the usual ListInstancePartitionOperationsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListInstancePartitionsAsyncPager

A pager for iterating through list_instance_partitions requests.

This class thinly wraps an initial ListInstancePartitionsResponse object, and provides an __aiter__ method to iterate through its instance_partitions field.

If there are more pages, the __aiter__ method will make additional ListInstancePartitions requests and continue to iterate through the instance_partitions field on the corresponding responses.

All the usual ListInstancePartitionsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListInstancePartitionsPager

A pager for iterating through list_instance_partitions requests.

This class thinly wraps an initial ListInstancePartitionsResponse object, and provides an __iter__ method to iterate through its instance_partitions field.

If there are more pages, the __iter__ method will make additional ListInstancePartitions requests and continue to iterate through the instance_partitions field on the corresponding responses.

All the usual ListInstancePartitionsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListInstancesAsyncPager

A pager for iterating through list_instances requests.

This class thinly wraps an initial ListInstancesResponse object, and provides an __aiter__ method to iterate through its instances field.

If there are more pages, the __aiter__ method will make additional ListInstances requests and continue to iterate through the instances field on the corresponding responses.

All the usual ListInstancesResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListInstancesPager

A pager for iterating through list_instances requests.

This class thinly wraps an initial ListInstancesResponse object, and provides an __iter__ method to iterate through its instances field.

If there are more pages, the __iter__ method will make additional ListInstances requests and continue to iterate through the instances field on the corresponding responses.

All the usual ListInstancesResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

AutoscalingConfig

Autoscaling config for an instance.

AutoscalingLimits

The autoscaling limits for the instance. Users can define the minimum and maximum compute capacity allocated to the instance, and the autoscaler will only scale within that range. Users can either use nodes or processing units to specify the limits, but should use the same unit to set both the min_limit and max_limit.

This message has oneof_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. Setting any member of the oneof automatically clears all other members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

AutoscalingTargets

The autoscaling targets for an instance.

CreateInstanceConfigMetadata

Metadata type for the operation returned by CreateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfig].

CreateInstanceConfigRequest

The request for CreateInstanceConfigRequest][InstanceAdmin.CreateInstanceConfigRequest].

CreateInstanceMetadata

Metadata type for the operation returned by CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance].

CreateInstancePartitionMetadata

Metadata type for the operation returned by CreateInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstancePartition].

CreateInstancePartitionRequest

The request for CreateInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstancePartition].

CreateInstanceRequest

The request for CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance].

DeleteInstanceConfigRequest

The request for DeleteInstanceConfigRequest][InstanceAdmin.DeleteInstanceConfigRequest].

DeleteInstancePartitionRequest

The request for DeleteInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstancePartition].

DeleteInstanceRequest

The request for DeleteInstance][google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance].

FulfillmentPeriod

Indicates the expected fulfillment period of an operation.

Enum values:

FULFILLMENT_PERIOD_UNSPECIFIED (0):
    Not specified.
FULFILLMENT_PERIOD_NORMAL (1):
    Normal fulfillment period. The operation is
    expected to complete within minutes.
FULFILLMENT_PERIOD_EXTENDED (2):
    Extended fulfillment period. It can take up
    to an hour for the operation to complete.

GetInstanceConfigRequest

The request for GetInstanceConfigRequest][google.spanner.admin.instance.v1.InstanceAdmin.GetInstanceConfig].

GetInstancePartitionRequest

The request for GetInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.GetInstancePartition].

GetInstanceRequest

The request for GetInstance][google.spanner.admin.instance.v1.InstanceAdmin.GetInstance].

Instance

An isolated set of Cloud Spanner resources on which databases can be hosted.

LabelsEntry

The abstract base class for a message.

State

Indicates the current state of the instance.

Enum values:

STATE_UNSPECIFIED (0):
    Not specified.
CREATING (1):
    The instance is still being created.
    Resources may not be available yet, and
    operations such as database creation may not
    work.
READY (2):
    The instance is fully created and ready to do
    work such as creating databases.

InstanceConfig

A possible configuration for a Cloud Spanner instance. Configurations define the geographic placement of nodes and their replication.

LabelsEntry

The abstract base class for a message.

State

Indicates the current state of the instance config.

Enum values:

STATE_UNSPECIFIED (0):
    Not specified.
CREATING (1):
    The instance config is still being created.
READY (2):
    The instance config is fully created and
    ready to be used to create instances.

Type

The type of this configuration.

Enum values:

TYPE_UNSPECIFIED (0):
    Unspecified.
GOOGLE_MANAGED (1):
    Google managed configuration.
USER_MANAGED (2):
    User managed configuration.

InstancePartition

An isolated set of Cloud Spanner resources that databases can define placements on.

This message has oneof_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. Setting any member of the oneof automatically clears all other members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

State

Indicates the current state of the instance partition.

Enum values:

STATE_UNSPECIFIED (0):
    Not specified.
CREATING (1):
    The instance partition is still being
    created. Resources may not be available yet, and
    operations such as creating placements using
    this instance partition may not work.
READY (2):
    The instance partition is fully created and
    ready to do work such as creating placements and
    using in databases.

ListInstanceConfigOperationsRequest

The request for ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations].

ListInstanceConfigOperationsResponse

The response for ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations].

ListInstanceConfigsRequest

The request for ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs].

ListInstanceConfigsResponse

The response for ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs].

ListInstancePartitionOperationsRequest

The request for ListInstancePartitionOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitionOperations].

ListInstancePartitionOperationsResponse

The response for ListInstancePartitionOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitionOperations].

ListInstancePartitionsRequest

The request for ListInstancePartitions][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitions].

ListInstancePartitionsResponse

The response for ListInstancePartitions][google.spanner.admin.instance.v1.InstanceAdmin.ListInstancePartitions].

ListInstancesRequest

The request for ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances].

ListInstancesResponse

The response for ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances].

OperationProgress

Encapsulates progress related information for a Cloud Spanner long running instance operations.

ReplicaInfo

ReplicaType

Indicates the type of replica. See the replica types documentation <https://cloud.google.com/spanner/docs/replication#replica_types>__ for more details.

Enum values:

TYPE_UNSPECIFIED (0):
    Not specified.
READ_WRITE (1):
    Read-write replicas support both reads and writes. These
    replicas:
    -  Maintain a full copy of your data.
    -  Serve reads.
    -  Can vote whether to commit a write.
    -  Participate in leadership election.
    -  Are eligible to become a leader.
READ_ONLY (2):
    Read-only replicas only support reads (not writes).
    Read-only replicas:

    -  Maintain a full copy of your data.
    -  Serve reads.
    -  Do not participate in voting to commit writes.
    -  Are not eligible to become a leader.
WITNESS (3):
    Witness replicas don't support reads but do participate in
    voting to commit writes. Witness replicas:

    -  Do not maintain a full copy of data.
    -  Do not serve reads.
    -  Vote whether to commit writes.
    -  Participate in leader election but are not eligible to
       become leader.

UpdateInstanceConfigMetadata

Metadata type for the operation returned by UpdateInstanceConfig][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstanceConfig].

UpdateInstanceConfigRequest

The request for UpdateInstanceConfigRequest][InstanceAdmin.UpdateInstanceConfigRequest].

UpdateInstanceMetadata

Metadata type for the operation returned by UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance].

UpdateInstancePartitionMetadata

Metadata type for the operation returned by UpdateInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstancePartition].

UpdateInstancePartitionRequest

The request for UpdateInstancePartition][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstancePartition].

UpdateInstanceRequest

The request for UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance].

Batch

Accumulate mutations for transmission during commit.

MutationGroup

A container for mutations.

Clients should use xref_MutationGroups to obtain instances instead of directly creating instances.

MutationGroups

Accumulate mutation groups for transmission during batch_write.

Client

Client for interacting with Cloud Spanner API.

BatchCheckout

Context manager for using a batch from a database.

Inside the context manager, checks out a session from the database, creates a batch from it, making the batch available.

Caller must not use the batch to perform API requests outside the scope of the context manager.

BatchSnapshot

Wrapper for generating and processing read / query batches.

Database

Representation of a Cloud Spanner Database.

We can use a Database to:

  • create the database
  • reload the database
  • update the database
  • drop the database

MutationGroupsCheckout

Context manager for using mutation groups from a database.

Inside the context manager, checks out a session from the database, creates mutation groups from it, making the groups available.

Caller must not use the object to perform API requests outside the scope of the context manager.

SnapshotCheckout

Context manager for using a snapshot from a database.

Inside the context manager, checks out a session from the database, creates a snapshot from it, making the snapshot available.

Caller must not use the snapshot to perform API requests outside the scope of the context manager.

Instance

Representation of a Cloud Spanner Instance.

We can use a Instance to:

  • reload itself
  • create itself
  • update itself
  • delete itself

KeyRange

Identify range of table rows via start / end points.

Specify either a start_open or start_closed key, or defaults to start_closed = []. Specify either an end_open or end_closed key, or defaults to end_closed = []. However, at least one key has to be specified. If no keys are specified, ValueError is raised.

KeySet

Identify table rows via keys / ranges.

AbstractSessionPool

Specifies required API for concrete session pool implementations.

BurstyPool

Concrete session pool implementation:

  • "Pings" existing sessions via session.exists before returning them.

  • Creates a new session, rather than blocking, when get is called on an empty pool.

  • Discards the returned session, rather than blocking, when put is called on a full pool.

FixedSizePool

Concrete session pool implementation:

  • Pre-allocates / creates a fixed number of sessions.

  • "Pings" existing sessions via session.exists before returning them, and replaces expired sessions.

  • Blocks, with a timeout, when get is called on an empty pool. Raises after timing out.

  • Raises when put is called on a full pool. That error is never expected in normal practice, as users should be calling get followed by put whenever in need of a session.

PingingPool

Concrete session pool implementation:

  • Pre-allocates / creates a fixed number of sessions.

  • Sessions are used in "round-robin" order (LRU first).

  • "Pings" existing sessions in the background after a specified interval via an API call (session.ping()).

  • Blocks, with a timeout, when get is called on an empty pool. Raises after timing out.

  • Raises when put is called on a full pool. That error is never expected in normal practice, as users should be calling get followed by put whenever in need of a session.

The application is responsible for calling ping at appropriate times, e.g. from a background thread.

SessionCheckout

Context manager: hold session checked out from a pool.

TransactionPingingPool

Concrete session pool implementation:

Deprecated: TransactionPingingPool no longer begins a transaction for each of its sessions at startup. Hence the TransactionPingingPool is same as PingingPool and maybe removed in the future.

In addition to the features of PingingPool, this class creates and begins a transaction for each of its sessions at startup.

When a session is returned to the pool, if its transaction has been committed or rolled back, the pool creates a new transaction for the session and pushes the transaction onto a separate queue of "transactions to begin." The application is responsible for flushing this queue as appropriate via the pool's begin_pending_transactions method.

SpannerAsyncClient

Cloud Spanner API

The Cloud Spanner API can be used to manage sessions and execute transactions on data stored in Cloud Spanner databases.

SpannerClient

Cloud Spanner API

The Cloud Spanner API can be used to manage sessions and execute transactions on data stored in Cloud Spanner databases.

ListSessionsAsyncPager

A pager for iterating through list_sessions requests.

This class thinly wraps an initial ListSessionsResponse object, and provides an __aiter__ method to iterate through its sessions field.

If there are more pages, the __aiter__ method will make additional ListSessions requests and continue to iterate through the sessions field on the corresponding responses.

All the usual ListSessionsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

ListSessionsPager

A pager for iterating through list_sessions requests.

This class thinly wraps an initial ListSessionsResponse object, and provides an __iter__ method to iterate through its sessions field.

If there are more pages, the __iter__ method will make additional ListSessions requests and continue to iterate through the sessions field on the corresponding responses.

All the usual ListSessionsResponse attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup.

Session

Representation of a Cloud Spanner Session.

We can use a Session to:

  • create the session
  • Use exists to check for the existence of the session
  • drop the session

Snapshot

Allow a set of reads / SQL statements with shared staleness.

See https://cloud.google.com/spanner/reference/rpc/google.spanner.v1#google.spanner.v1.TransactionOptions.ReadOnly

If no options are passed, reads will use the strong model, reading at a timestamp where all previously committed transactions are visible.

StreamedResultSet

Process a sequence of partial result sets into a single set of row data.

Unmergeable

Unable to merge two values.

Table

Representation of a Cloud Spanner Table.

Transaction

Implement read-write transaction semantics for a session.

BatchCreateSessionsRequest

The request for BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].

BatchCreateSessionsResponse

The response for BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].

BatchWriteRequest

The request for BatchWrite][google.spanner.v1.Spanner.BatchWrite].

MutationGroup

A group of mutations to be committed together. Related mutations should be placed in a group. For example, two mutations inserting rows with the same primary key prefix in both parent and child tables are related.

BatchWriteResponse

The result of applying a batch of mutations.

BeginTransactionRequest

The request for BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].

CommitRequest

The request for Commit][google.spanner.v1.Spanner.Commit].

This message has oneof_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. Setting any member of the oneof automatically clears all other members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

CommitResponse

The response for Commit][google.spanner.v1.Spanner.Commit].

CommitStats

Additional statistics about a commit.

CreateSessionRequest

The request for CreateSession][google.spanner.v1.Spanner.CreateSession].

DeleteSessionRequest

The request for DeleteSession][google.spanner.v1.Spanner.DeleteSession].

DirectedReadOptions

The DirectedReadOptions can be used to indicate which replicas or regions should be used for non-transactional reads or queries.

DirectedReadOptions may only be specified for a read-only transaction, otherwise the API will return an INVALID_ARGUMENT error.

This message has oneof_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. Setting any member of the oneof automatically clears all other members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

ExcludeReplicas

An ExcludeReplicas contains a repeated set of ReplicaSelection that should be excluded from serving requests.

IncludeReplicas

An IncludeReplicas contains a repeated set of ReplicaSelection which indicates the order in which replicas should be considered.

ReplicaSelection

The directed read replica selector. Callers must provide one or more of the following fields for replica selection:

  • location - The location must be one of the regions within the multi-region configuration of your database.
  • type - The type of the replica.

Some examples of using replica_selectors are:

  • location:us-east1 --> The "us-east1" replica(s) of any available type will be used to process the request.
  • type:READ_ONLY --> The "READ_ONLY" type replica(s) in nearest available location will be used to process the request.
  • location:us-east1 type:READ_ONLY --> The "READ_ONLY" type replica(s) in location "us-east1" will be used to process the request.

Type

Indicates the type of replica.

Enum values:

TYPE_UNSPECIFIED (0):
    Not specified.
READ_WRITE (1):
    Read-write replicas support both reads and
    writes.
READ_ONLY (2):
    Read-only replicas only support reads (not
    writes).

ExecuteBatchDmlRequest

The request for ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml].

Statement

A single DML statement.

ParamTypesEntry

The abstract base class for a message.

ExecuteBatchDmlResponse

The response for ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list of ResultSet][google.spanner.v1.ResultSet] messages, one for each DML statement that has successfully executed, in the same order as the statements in the request. If a statement fails, the status in the response body identifies the cause of the failure.

To check for DML statements that failed, use the following approach:

  1. Check the status in the response message. The google.rpc.Code][google.rpc.Code] enum value OK indicates that all statements were executed successfully.
  2. If the status was not OK, check the number of result sets in the response. If the response contains N ResultSet][google.spanner.v1.ResultSet] messages, then statement N+1 in the request failed.

Example 1:

  • Request: 5 DML statements, all executed successfully.
  • Response: 5 ResultSet][google.spanner.v1.ResultSet] messages, with the status OK.

Example 2:

  • Request: 5 DML statements. The third statement has a syntax error.
  • Response: 2 ResultSet][google.spanner.v1.ResultSet] messages, and a syntax error (INVALID_ARGUMENT) status. The number of ResultSet][google.spanner.v1.ResultSet] messages indicates that the third statement failed, and the fourth and fifth statements were not executed.

ExecuteSqlRequest

The request for ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql].

ParamTypesEntry

The abstract base class for a message.

QueryMode

Mode in which the statement must be processed.

Enum values:

NORMAL (0):
    The default mode. Only the statement results
    are returned.
PLAN (1):
    This mode returns only the query plan,
    without any results or execution statistics
    information.
PROFILE (2):
    This mode returns both the query plan and the
    execution statistics along with the results.

QueryOptions

Query optimizer configuration.

GetSessionRequest

The request for GetSession][google.spanner.v1.Spanner.GetSession].

KeyRange

KeyRange represents a range of rows in a table or index.

A range has a start key and an end key. These keys can be open or closed, indicating if the range includes rows with that key.

Keys are represented by lists, where the ith value in the list corresponds to the ith component of the table or index primary key. Individual values are encoded as described here][google.spanner.v1.TypeCode].

For example, consider the following table definition:

::

CREATE TABLE UserEvents (
  UserName STRING(MAX),
  EventDate STRING(10)
) PRIMARY KEY(UserName, EventDate);

The following keys name rows in this table:

::

["Bob", "2014-09-23"]
["Alfred", "2015-06-12"]

Since the UserEvents table's PRIMARY KEY clause names two columns, each UserEvents key has two elements; the first is the UserName, and the second is the EventDate.

Key ranges with multiple components are interpreted lexicographically by component using the table or index key's declared sort order. For example, the following range returns all events for user "Bob" that occurred in the year 2015:

::

"start_closed": ["Bob", "2015-01-01"]
"end_closed": ["Bob", "2015-12-31"]

Start and end keys can omit trailing key components. This affects the inclusion and exclusion of rows that exactly match the provided key components: if the key is closed, then rows that exactly match the provided components are included; if the key is open, then rows that exactly match are not included.

For example, the following range includes all events for "Bob" that occurred during and after the year 2000:

::

"start_closed": ["Bob", "2000-01-01"]
"end_closed": ["Bob"]

The next example retrieves all events for "Bob":

::

"start_closed": ["Bob"]
"end_closed": ["Bob"]

To retrieve events before the year 2000:

::

"start_closed": ["Bob"]
"end_open": ["Bob", "2000-01-01"]

The following range includes all rows in the table:

::

"start_closed": []
"end_closed": []

This range returns all users whose UserName begins with any character from A to C:

::

"start_closed": ["A"]
"end_open": ["D"]

This range returns all users whose UserName begins with B:

::

"start_closed": ["B"]
"end_open": ["C"]

Key ranges honor column sort order. For example, suppose a table is defined as follows:

::

CREATE TABLE DescendingSortedTable {
  Key INT64,
  ...
) PRIMARY KEY(Key DESC);

The following range retrieves all rows with key values between 1 and 100 inclusive:

::

"start_closed": ["100"]
"end_closed": ["1"]

Note that 100 is passed as the start, and 1 is passed as the end, because Key is a descending column in the schema.

This message has oneof_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. Setting any member of the oneof automatically clears all other members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

KeySet

KeySet defines a collection of Cloud Spanner keys and/or key ranges. All the keys are expected to be in the same table or index. The keys need not be sorted in any particular way.

If the same key is specified multiple times in the set (for example if two ranges, two keys, or a key and a range overlap), Cloud Spanner behaves as if the key were only specified once.

ListSessionsRequest

The request for ListSessions][google.spanner.v1.Spanner.ListSessions].

ListSessionsResponse

The response for ListSessions][google.spanner.v1.Spanner.ListSessions].

Mutation

A modification to one or more Cloud Spanner rows. Mutations can be applied to a Cloud Spanner database by sending them in a Commit][google.spanner.v1.Spanner.Commit] call.

This message has oneof_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. Setting any member of the oneof automatically clears all other members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

Delete

Arguments to delete][google.spanner.v1.Mutation.delete] operations.

Write

Arguments to insert][google.spanner.v1.Mutation.insert], update][google.spanner.v1.Mutation.update], insert_or_update][google.spanner.v1.Mutation.insert_or_update], and replace][google.spanner.v1.Mutation.replace] operations.

PartialResultSet

Partial results from a streaming read or SQL query. Streaming reads and SQL queries better tolerate large result sets, large rows, and large values, but are a little trickier to consume.

Partition

Information returned for each partition returned in a PartitionResponse.

PartitionOptions

Options for a PartitionQueryRequest and PartitionReadRequest.

PartitionQueryRequest

The request for PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]

ParamTypesEntry

The abstract base class for a message.

PartitionReadRequest

The request for PartitionRead][google.spanner.v1.Spanner.PartitionRead]

PartitionResponse

The response for PartitionQuery][google.spanner.v1.Spanner.PartitionQuery] or PartitionRead][google.spanner.v1.Spanner.PartitionRead]

PlanNode

Node information for nodes appearing in a QueryPlan.plan_nodes][google.spanner.v1.QueryPlan.plan_nodes].

Metadata associated with a parent-child relationship appearing in a PlanNode][google.spanner.v1.PlanNode].

Kind

The kind of PlanNode][google.spanner.v1.PlanNode]. Distinguishes between the two different kinds of nodes that can appear in a query plan.

Enum values:

KIND_UNSPECIFIED (0):
    Not specified.
RELATIONAL (1):
    Denotes a Relational operator node in the expression tree.
    Relational operators represent iterative processing of rows
    during query execution. For example, a `TableScan`
    operation that reads rows from a table.
SCALAR (2):
    Denotes a Scalar node in the expression tree.
    Scalar nodes represent non-iterable entities in
    the query plan. For example, constants or
    arithmetic operators appearing inside predicate
    expressions or references to column names.

ShortRepresentation

Condensed representation of a node and its subtree. Only present for SCALAR [PlanNode(s)][google.spanner.v1.PlanNode].

SubqueriesEntry

The abstract base class for a message.

QueryPlan

Contains an ordered list of nodes appearing in the query plan.

ReadRequest

The request for Read][google.spanner.v1.Spanner.Read] and StreamingRead][google.spanner.v1.Spanner.StreamingRead].

RequestOptions

Common request options for various APIs.

Priority

The relative priority for requests. Note that priority is not applicable for BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].

The priority acts as a hint to the Cloud Spanner scheduler and does not guarantee priority or order of execution. For example:

  • Some parts of a write operation always execute at PRIORITY_HIGH, regardless of the specified priority. This may cause you to see an increase in high priority workload even when executing a low priority request. This can also potentially cause a priority inversion where a lower priority request will be fulfilled ahead of a higher priority request.
  • If a transaction contains multiple operations with different priorities, Cloud Spanner does not guarantee to process the higher priority operations first. There may be other constraints to satisfy, such as order of operations.

Enum values:

PRIORITY_UNSPECIFIED (0):
    `PRIORITY_UNSPECIFIED` is equivalent to `PRIORITY_HIGH`.
PRIORITY_LOW (1):
    This specifies that the request is low
    priority.
PRIORITY_MEDIUM (2):
    This specifies that the request is medium
    priority.
PRIORITY_HIGH (3):
    This specifies that the request is high
    priority.

ResultSet

Results from Read][google.spanner.v1.Spanner.Read] or ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].

ResultSetMetadata

Metadata about a ResultSet][google.spanner.v1.ResultSet] or PartialResultSet][google.spanner.v1.PartialResultSet].

ResultSetStats

Additional statistics about a ResultSet][google.spanner.v1.ResultSet] or PartialResultSet][google.spanner.v1.PartialResultSet].

This message has oneof_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. Setting any member of the oneof automatically clears all other members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

RollbackRequest

The request for Rollback][google.spanner.v1.Spanner.Rollback].

Session

A session in the Cloud Spanner API.

LabelsEntry

The abstract base class for a message.

StructType

StructType defines the fields of a STRUCT][google.spanner.v1.TypeCode.STRUCT] type.

Field

Message representing a single field of a struct.

Transaction

A transaction.

TransactionOptions

Transactions:

Each session can have at most one active transaction at a time (note that standalone reads and queries use a transaction internally and do count towards the one transaction limit). After the active transaction is completed, the session can immediately be re-used for the next transaction. It is not necessary to create a new session for each transaction.

Transaction modes:

Cloud Spanner supports three transaction modes:

  1. Locking read-write. This type of transaction is the only way to write data into Cloud Spanner. These transactions rely on pessimistic locking and, if necessary, two-phase commit. Locking read-write transactions may abort, requiring the application to retry.

  2. Snapshot read-only. Snapshot read-only transactions provide guaranteed consistency across several reads, but do not allow writes. Snapshot read-only transactions can be configured to read at timestamps in the past, or configured to perform a strong read (where Spanner will select a timestamp such that the read is guaranteed to see the effects of all transactions that have committed before the start of the read). Snapshot read-only transactions do not need to be committed.

    Queries on change streams must be performed with the snapshot read-only transaction mode, specifying a strong read. Please see TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong] for more details.

  3. Partitioned DML. This type of transaction is used to execute a single Partitioned DML statement. Partitioned DML partitions the key space and runs the DML statement over each partition in parallel using separate, internal transactions that commit independently. Partitioned DML transactions do not need to be committed.

For transactions that only read, snapshot read-only transactions provide simpler semantics and are almost always faster. In particular, read-only transactions do not take locks, so they do not conflict with read-write transactions. As a consequence of not taking locks, they also do not abort, so retry loops are not needed.

Transactions may only read-write data in a single database. They may, however, read-write data in different tables within that database.

Locking read-write transactions:

Locking transactions may be used to atomically read-modify-write data anywhere in a database. This type of transaction is externally consistent.

Clients should attempt to minimize the amount of time a transaction is active. Faster transactions commit with higher probability and cause less contention. Cloud Spanner attempts to keep read locks active as long as the transaction continues to do reads, and the transaction has not been terminated by Commit][google.spanner.v1.Spanner.Commit] or Rollback][google.spanner.v1.Spanner.Rollback]. Long periods of inactivity at the client may cause Cloud Spanner to release a transaction's locks and abort it.

Conceptually, a read-write transaction consists of zero or more reads or SQL statements followed by Commit][google.spanner.v1.Spanner.Commit]. At any time before Commit][google.spanner.v1.Spanner.Commit], the client can send a Rollback][google.spanner.v1.Spanner.Rollback] request to abort the transaction.

Semantics:

Cloud Spanner can commit the transaction if all read locks it acquired are still valid at commit time, and it is able to acquire write locks for all writes. Cloud Spanner can abort the transaction for any reason. If a commit attempt returns ABORTED, Cloud Spanner guarantees that the transaction has not modified any user data in Cloud Spanner.

Unless the transaction commits, Cloud Spanner makes no guarantees about how long the transaction's locks were held for. It is an error to use Cloud Spanner locks for any sort of mutual exclusion other than between Cloud Spanner transactions themselves.

Retrying aborted transactions:

When a transaction aborts, the application can choose to retry the whole transaction again. To maximize the chances of successfully committing the retry, the client should execute the retry in the same session as the original attempt. The original session's lock priority increases with each consecutive abort, meaning that each attempt has a slightly better chance of success than the previous.

Under some circumstances (for example, many transactions attempting to modify the same row(s)), a transaction can abort many times in a short period before successfully committing. Thus, it is not a good idea to cap the number of retries a transaction can attempt; instead, it is better to limit the total amount of time spent retrying.

Idle transactions:

A transaction is considered idle if it has no outstanding reads or SQL queries and has not started a read or SQL query within the last 10 seconds. Idle transactions can be aborted by Cloud Spanner so that they don't hold on to locks indefinitely. If an idle transaction is aborted, the commit will fail with error ABORTED.

If this behavior is undesirable, periodically executing a simple SQL query in the transaction (for example, SELECT 1) prevents the transaction from becoming idle.

Snapshot read-only transactions:

Snapshot read-only transactions provides a simpler method than locking read-write transactions for doing several consistent reads. However, this type of transaction does not support writes.

Snapshot transactions do not take locks. Instead, they work by choosing a Cloud Spanner timestamp, then executing all reads at that timestamp. Since they do not acquire locks, they do not block concurrent read-write transactions.

Unlike locking read-write transactions, snapshot read-only transactions never abort. They can fail if the chosen read timestamp is garbage collected; however, the default garbage collection policy is generous enough that most applications do not need to worry about this in practice.

Snapshot read-only transactions do not need to call Commit][google.spanner.v1.Spanner.Commit] or Rollback][google.spanner.v1.Spanner.Rollback] (and in fact are not permitted to do so).

To execute a snapshot transaction, the client specifies a timestamp bound, which tells Cloud Spanner how to choose a read timestamp.

The types of timestamp bound are:

  • Strong (the default).
  • Bounded staleness.
  • Exact staleness.

If the Cloud Spanner database to be read is geographically distributed, stale read-only transactions can execute more quickly than strong or read-write transactions, because they are able to execute far from the leader replica.

Each type of timestamp bound is discussed in detail below.

Strong: Strong reads are guaranteed to see the effects of all transactions that have committed before the start of the read. Furthermore, all rows yielded by a single read are consistent with each other -- if any part of the read observes a transaction, all parts of the read see the transaction.

Strong reads are not repeatable: two consecutive strong read-only transactions might return inconsistent results if there are concurrent writes. If consistency across reads is required, the reads should be executed within a transaction or at an exact read timestamp.

Queries on change streams (see below for more details) must also specify the strong read timestamp bound.

See TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong].

Exact staleness:

These timestamp bounds execute reads at a user-specified timestamp. Reads at a timestamp are guaranteed to see a consistent prefix of the global transaction history: they observe modifications done by all transactions with a commit timestamp less than or equal to the read timestamp, and observe none of the modifications done by transactions with a larger commit timestamp. They will block until all conflicting transactions that may be assigned commit timestamps <= the read timestamp have finished.

The timestamp can either be expressed as an absolute Cloud Spanner commit timestamp or a staleness relative to the current time.

These modes do not require a "negotiation phase" to pick a timestamp. As a result, they execute slightly faster than the equivalent boundedly stale concurrency modes. On the other hand, boundedly stale reads usually return fresher results.

See TransactionOptions.ReadOnly.read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read_timestamp] and TransactionOptions.ReadOnly.exact_staleness][google.spanner.v1.TransactionOptions.ReadOnly.exact_staleness].

Bounded staleness:

Bounded staleness modes allow Cloud Spanner to pick the read timestamp, subject to a user-provided staleness bound. Cloud Spanner chooses the newest timestamp within the staleness bound that allows execution of the reads at the closest available replica without blocking.

All rows yielded are consistent with each other -- if any part of the read observes a transaction, all parts of the read see the transaction. Boundedly stale reads are not repeatable: two stale reads, even if they use the same staleness bound, can execute at different timestamps and thus return inconsistent results.

Boundedly stale reads execute in two phases: the first phase negotiates a timestamp among all replicas needed to serve the read. In the second phase, reads are executed at the negotiated timestamp.

As a result of the two phase execution, bounded staleness reads are usually a little slower than comparable exact staleness reads. However, they are typically able to return fresher results, and are more likely to execute at the closest replica.

Because the timestamp negotiation requires up-front knowledge of which rows will be read, it can only be used with single-use read-only transactions.

See TransactionOptions.ReadOnly.max_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max_staleness] and TransactionOptions.ReadOnly.min_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.min_read_timestamp].

Old read timestamps and garbage collection:

Cloud Spanner continuously garbage collects deleted and overwritten data in the background to reclaim storage space. This process is known as "version GC". By default, version GC reclaims versions after they are one hour old. Because of this, Cloud Spanner cannot perform reads at read timestamps more than one hour in the past. This restriction also applies to in-progress reads and/or SQL queries whose timestamp become too old while executing. Reads and SQL queries with too-old read timestamps fail with the error FAILED_PRECONDITION.

You can configure and extend the VERSION_RETENTION_PERIOD of a database up to a period as long as one week, which allows Cloud Spanner to perform reads up to one week in the past.

Querying change Streams:

A Change Stream is a schema object that can be configured to watch data changes on the entire database, a set of tables, or a set of columns in a database.

When a change stream is created, Spanner automatically defines a corresponding SQL Table-Valued Function (TVF) that can be used to query the change records in the associated change stream using the ExecuteStreamingSql API. The name of the TVF for a change stream is generated from the name of the change stream: READ_<change_stream_name>.

All queries on change stream TVFs must be executed using the ExecuteStreamingSql API with a single-use read-only transaction with a strong read-only timestamp_bound. The change stream TVF allows users to specify the start_timestamp and end_timestamp for the time range of interest. All change records within the retention period is accessible using the strong read-only timestamp_bound. All other TransactionOptions are invalid for change stream queries.

In addition, if TransactionOptions.read_only.return_read_timestamp is set to true, a special value of 2^63 - 2 will be returned in the Transaction][google.spanner.v1.Transaction] message that describes the transaction, instead of a valid read timestamp. This special value should be discarded and not used for any subsequent queries.

Please see https://cloud.google.com/spanner/docs/change-streams for more details on how to query the change stream TVFs.

Partitioned DML transactions:

Partitioned DML transactions are used to execute DML statements with a different execution strategy that provides different, and often better, scalability properties for large, table-wide operations than DML in a ReadWrite transaction. Smaller scoped statements, such as an OLTP workload, should prefer using ReadWrite transactions.

Partitioned DML partitions the keyspace and runs the DML statement on each partition in separate, internal transactions. These transactions commit automatically when complete, and run independently from one another.

To reduce lock contention, this execution strategy only acquires read locks on rows that match the WHERE clause of the statement. Additionally, the smaller per-partition transactions hold locks for less time.

That said, Partitioned DML is not a drop-in replacement for standard DML used in ReadWrite transactions.

  • The DML statement must be fully-partitionable. Specifically, the statement must be expressible as the union of many statements which each access only a single row of the table.

  • The statement is not applied atomically to all rows of the table. Rather, the statement is applied atomically to partitions of the table, in independent transactions. Secondary index rows are updated atomically with the base table rows.

  • Partitioned DML does not guarantee exactly-once execution semantics against a partition. The statement will be applied at least once to each partition. It is strongly recommended that the DML statement should be idempotent to avoid unexpected results. For instance, it is potentially dangerous to run a statement such as UPDATE table SET column = column + 1 as it could be run multiple times against some rows.

  • The partitions are committed automatically - there is no support for Commit or Rollback. If the call returns an error, or if the client issuing the ExecuteSql call dies, it is possible that some rows had the statement executed on them successfully. It is also possible that statement was never executed against other rows.

  • Partitioned DML transactions may only contain the execution of a single DML statement via ExecuteSql or ExecuteStreamingSql.

  • If any error is encountered during the execution of the partitioned DML operation (for instance, a UNIQUE INDEX violation, division by zero, or a value that cannot be stored due to schema constraints), then the operation is stopped at that point and an error is returned. It is possible that at this point, some partitions have been committed (or even committed multiple times), and other partitions have not been run at all.

Given the above, Partitioned DML is good fit for large, database-wide, operations that are idempotent, such as deleting old rows from a very large table.

This message has oneof_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. Setting any member of the oneof automatically clears all other members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

PartitionedDml

Message type to initiate a Partitioned DML transaction.

ReadOnly

Message type to initiate a read-only transaction.

This message has oneof_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. Setting any member of the oneof automatically clears all other members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

ReadWrite

Message type to initiate a read-write transaction. Currently this transaction type has no options.

ReadLockMode

ReadLockMode is used to set the read lock mode for read-write transactions.

Enum values:

READ_LOCK_MODE_UNSPECIFIED (0):
    Default value.
    If the value is not specified, the pessimistic
    read lock is used.
PESSIMISTIC (1):
    Pessimistic lock mode.

    Read locks are acquired immediately on read.
OPTIMISTIC (2):
    Optimistic lock mode.

    Locks for reads within the transaction are not
    acquired on read. Instead the locks are acquired
    on a commit to validate that read/queried data
    has not changed since the transaction started.

TransactionSelector

This message is used to select the transaction in which a Read][google.spanner.v1.Spanner.Read] or ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] call runs.

See TransactionOptions][google.spanner.v1.TransactionOptions] for more information about transactions.

This message has oneof_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. Setting any member of the oneof automatically clears all other members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

Type

Type indicates the type of a Cloud Spanner value, as might be stored in a table cell or returned from an SQL query.

TypeAnnotationCode

TypeAnnotationCode is used as a part of Type][google.spanner.v1.Type] to disambiguate SQL types that should be used for a given Cloud Spanner value. Disambiguation is needed because the same Cloud Spanner type can be mapped to different SQL types depending on SQL dialect. TypeAnnotationCode doesn't affect the way value is serialized.

Enum values:

TYPE_ANNOTATION_CODE_UNSPECIFIED (0):
    Not specified.
PG_NUMERIC (2):
    PostgreSQL compatible NUMERIC type. This annotation needs to
    be applied to `Type][google.spanner.v1.Type]` instances
    having `NUMERIC][google.spanner.v1.TypeCode.NUMERIC]` type
    code to specify that values of this type should be treated
    as PostgreSQL NUMERIC values. Currently this annotation is
    always needed for
    `NUMERIC][google.spanner.v1.TypeCode.NUMERIC]` when a client
    interacts with PostgreSQL-enabled Spanner databases.
PG_JSONB (3):
    PostgreSQL compatible JSONB type. This annotation needs to
    be applied to `Type][google.spanner.v1.Type]` instances
    having `JSON][google.spanner.v1.TypeCode.JSON]` type code to
    specify that values of this type should be treated as
    PostgreSQL JSONB values. Currently this annotation is always
    needed for `JSON][google.spanner.v1.TypeCode.JSON]` when a
    client interacts with PostgreSQL-enabled Spanner databases.
PG_OID (4):
    PostgreSQL compatible OID type. This
    annotation can be used by a client interacting
    with PostgreSQL-enabled Spanner database to
    specify that a value should be treated using the
    semantics of the OID type.

TypeCode

TypeCode is used as part of Type][google.spanner.v1.Type] to indicate the type of a Cloud Spanner value.

Each legal value of a type can be encoded to or decoded from a JSON value, using the encodings described below. All Cloud Spanner values can be null, regardless of type; null\ s are always encoded as a JSON null.

Enum values:

TYPE_CODE_UNSPECIFIED (0):
    Not specified.
BOOL (1):
    Encoded as JSON `true` or `false`.
INT64 (2):
    Encoded as `string`, in decimal format.
FLOAT64 (3):
    Encoded as `number`, or the strings `"NaN"`,
    `"Infinity"`, or `"-Infinity"`.
FLOAT32 (15):
    Encoded as `number`, or the strings `"NaN"`,
    `"Infinity"`, or `"-Infinity"`.
TIMESTAMP (4):
    Encoded as `string` in RFC 3339 timestamp format. The time
    zone must be present, and must be `"Z"`.
    If the schema has the column option
    `allow_commit_timestamp=true`, the placeholder string
    `"spanner.commit_timestamp()"` can be used to instruct the
    system to insert the commit timestamp associated with the
    transaction commit.
DATE (5):
    Encoded as `string` in RFC 3339 date format.
STRING (6):
    Encoded as `string`.
BYTES (7):
    Encoded as a base64-encoded `string`, as described in RFC
    4648, section 4.
ARRAY (8):
    Encoded as `list`, where the list elements are represented
    according to
    `array_element_type][google.spanner.v1.Type.array_element_type]`.
STRUCT (9):
    Encoded as `list`, where list element `i` is represented
    according to
    [struct_type.fields[i]][google.spanner.v1.StructType.fields].
NUMERIC (10):
    Encoded as `string`, in decimal format or scientific
    notation format. Decimal format: \ `[+-]Digits[.[Digits]]`
    or \ `[+-][Digits].Digits`

    Scientific notation:
    \ `[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or
    \ `[+-][Digits].Digits[ExponentIndicator[+-]Digits]`
    (ExponentIndicator is `"e"` or `"E"`)
JSON (11):
    Encoded as a JSON-formatted `string` as described in RFC
    7159. The following rules are applied when parsing JSON
    input:

    -  Whitespace characters are not preserved.
    -  If a JSON object has duplicate keys, only the first key
       is preserved.
    -  Members of a JSON object are not guaranteed to have their
       order preserved.
    -  JSON array elements will have their order preserved.
PROTO (13):
    Encoded as a base64-encoded `string`, as described in RFC
    4648, section 4.
ENUM (14):
    Encoded as `string`, in decimal format.

Modules

pagers

API documentation for spanner_admin_database_v1.services.database_admin.pagers module.

pagers

API documentation for spanner_admin_instance_v1.services.instance_admin.pagers module.

batch

Context manager for Cloud Spanner batched writes.

client

Parent client for calling the Cloud Spanner API.

This is the base from which all interactions with the API occur.

In the hierarchy of API concepts

database

User-friendly container for Cloud Spanner Database.

instance

User friendly container for Cloud Spanner Instance.

keyset

Wrap representation of Spanner keys / ranges.

pool

Pools managing shared Session objects.

pagers

API documentation for spanner_v1.services.spanner.pagers module.

session

Wrapper for Cloud Spanner Session objects.

snapshot

Model a set of read-only queries to a database as a snapshot.

streamed

Wrapper for streaming results.

table

User friendly container for Cloud Spanner Table.

transaction

Spanner read-write transaction support.