Bigtable Data Client Async¶
Note
It is generally not recommended to use the async client in an otherwise synchronous codebase. To make use of asyncio’s performance benefits, the codebase should be designed to be async from the ground up.
- class google.cloud.bigtable.data._async.client.BigtableDataClientAsync(*, project: str | None = None, pool_size: int = 3, credentials: google.auth.credentials.Credentials | None = None, client_options: dict[str, Any] | 'google.api_core.client_options.ClientOptions' | None = None)[source]¶
Bases:
google.cloud.client.ClientWithProject
Create a client instance for the Bigtable Data API
Client should be created within an async context (running event loop)
- Parameters
project – the project which the client acts on behalf of. If not passed, falls back to the default inferred from the environment.
pool_size – The number of grpc channels to maintain in the internal channel pool.
credentials – Thehe OAuth2 Credentials to use for this client. If not passed (and if no
_http
object is passed), falls back to the default inferred from the environment.client_options – Client options used to set user options on the client. API Endpoint should be set through client_options.
- Raises
RuntimeError – if called outside of an async context (no running event loop)
ValueError – if pool_size is less than 1
- async execute_query(query: str, instance_id: str, *, parameters: Dict[str, ExecuteQueryValueType] | None = None, parameter_types: Dict[str, SqlType.Type] | None = None, app_profile_id: str | None = None, operation_timeout: float = 600, attempt_timeout: float | None = 20, retryable_errors: Sequence[type[Exception]] = (<class 'google.api_core.exceptions.DeadlineExceeded'>, <class 'google.api_core.exceptions.ServiceUnavailable'>, <class 'google.api_core.exceptions.Aborted'>)) ExecuteQueryIteratorAsync [source]¶
Executes an SQL query on an instance. Returns an iterator to asynchronously stream back columns from selected rows.
Failed requests within operation_timeout will be retried based on the retryable_errors list until operation_timeout is reached.
- Parameters
query – Query to be run on Bigtable instance. The query can use
@param
placeholders to use parameter interpolation on the server. Values for all parameters should be provided inparameters
. Types of parameters are inferred but should be provided inparameter_types
if the inference is not possible (i.e. when value can be None, an empty list or an empty dict).instance_id – The Bigtable instance ID to perform the query on. instance_id is combined with the client’s project to fully specify the instance.
parameters – Dictionary with values for all parameters used in the
query
.parameter_types – Dictionary with types of parameters used in the
query
. Required to contain entries only for parameters whose type cannot be detected automatically (i.e. the value can be None, an empty list or an empty dict).app_profile_id – The app profile to associate with requests. https://cloud.google.com/bigtable/docs/app-profiles
operation_timeout – the time budget for the entire operation, in seconds. Failed requests will be retried within the budget. Defaults to 600 seconds.
attempt_timeout – the time budget for an individual network request, in seconds. If it takes longer than this time to complete, the request will be cancelled with a DeadlineExceeded exception, and a retry will be attempted. Defaults to the 20 seconds. If None, defaults to operation_timeout.
retryable_errors – a list of errors that will be retried if encountered. Defaults to 4 (DeadlineExceeded), 14 (ServiceUnavailable), and 10 (Aborted)
- Returns
an asynchronous iterator that yields rows returned by the query
- Return type
- Raises
google.api_core.exceptions.DeadlineExceeded – raised after operation timeout will be chained with a RetryExceptionGroup containing GoogleAPIError exceptions from any retries that failed
google.api_core.exceptions.GoogleAPIError – raised if the request encounters an unrecoverable error
- get_table(instance_id: str, table_id: str, *args, **kwargs) google.cloud.bigtable.data._async.client.TableAsync [source]¶
Returns a table instance for making data API requests. All arguments are passed directly to the TableAsync constructor.
- Parameters
instance_id – The Bigtable instance ID to associate with this client. instance_id is combined with the client’s project to fully specify the instance
table_id – The ID of the table. table_id is combined with the instance_id and the client’s project to fully specify the table
app_profile_id – The app profile to associate with requests. https://cloud.google.com/bigtable/docs/app-profiles
default_read_rows_operation_timeout – The default timeout for read rows operations, in seconds. If not set, defaults to 600 seconds (10 minutes)
default_read_rows_attempt_timeout – The default timeout for individual read rows rpc requests, in seconds. If not set, defaults to 20 seconds
default_mutate_rows_operation_timeout – The default timeout for mutate rows operations, in seconds. If not set, defaults to 600 seconds (10 minutes)
default_mutate_rows_attempt_timeout – The default timeout for individual mutate rows rpc requests, in seconds. If not set, defaults to 60 seconds
default_operation_timeout – The default timeout for all other operations, in seconds. If not set, defaults to 60 seconds
default_attempt_timeout – The default timeout for all other individual rpc requests, in seconds. If not set, defaults to 20 seconds
default_read_rows_retryable_errors – a list of errors that will be retried if encountered during read_rows and related operations. Defaults to 4 (DeadlineExceeded), 14 (ServiceUnavailable), and 10 (Aborted)
default_mutate_rows_retryable_errors – a list of errors that will be retried if encountered during mutate_rows and related operations. Defaults to 4 (DeadlineExceeded) and 14 (ServiceUnavailable)
default_retryable_errors – a list of errors that will be retried if encountered during all other operations. Defaults to 4 (DeadlineExceeded) and 14 (ServiceUnavailable)
- Returns
a table instance for making data API requests
- Return type
- Raises
RuntimeError – if called outside of an async context (no running event loop)