Bucket

class txcouchbase.bucket.Bucket(cluster: Cluster, bucket_name: str)

A bucket in a cluster: its scopes and collections, and the operations run against it.

Get one from bucket().

Parameters:
  • cluster (Cluster) – The cluster the bucket belongs to.

  • bucket_name (str) – The name of the bucket.

close() → Deferred

Shuts down this bucket instance. Cleaning up all resources associated with it.

Warning

Use of this method is almost always unnecessary. Bucket resources should be cleaned up once the bucket instance falls out of scope. However, in some applications tuning resources is necessary and in those types of applications, this method might be beneficial.

collection(collection_name: str) → Collection

Creates a Collection instance of the specified collection.

Parameters:

collection_name (str) – Name of the collection to reference.

Returns:

A Collection instance of the specified collection.

Return type:

Collection

collections() → CollectionManager

Get a manager for the scopes and collections of this bucket.

Returns:

A CollectionManager instance.

Return type:

CollectionManager

default_collection() → Collection

Creates a Collection instance of the default collection.

Returns:

A Collection instance of the default collection.

Return type:

Collection

default_scope() → Scope

Creates a Scope instance of the default scope.

Returns:

A Scope instance of the default scope.

Return type:

Scope

property name: str

The name of this bucket.

on_connect() → Deferred[None]

Wait until the bucket is open.

Returns:

Fires once the bucket is open, or fails if it cannot be opened.

Return type:

Deferred

ping(opts: PingOptions | None = None, **kwargs: Unpack[PingOptionsKwargs]) → Deferred[PingResult]

Performs a ping operation against the bucket.

The ping operation pings the services which are specified (or all services if none are specified). Returns a report which describes the outcome of the ping operations which were performed.

Parameters:
  • opts (PingOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used in place or to override provided PingOptions

Returns:

A report which describes the outcome of the ping operations which were performed.

Return type:

Deferred[PingResult]

scope(name: str) → Scope

Creates a Scope instance of the specified scope.

Parameters:

name (str) – Name of the scope to reference.

Returns:

A Scope instance of the specified scope.

Return type:

Scope

view_indexes() → ViewIndexManager

Get a manager for the view design documents and views of this bucket.

Deprecated since version 4.6.0: Views are deprecated in Couchbase Server 7.0+, and will be removed from a future server version. Views are not compatible with the Magma storage engine. Instead of views, use indexes and queries using the Index Service (GSI) and the Query Service (SQL++).

Returns:

A ViewIndexManager instance.

Return type:

ViewIndexManager

view_query(design_doc: str, view_name: str, view_options: ViewOptions | None = None, **kwargs: Unpack[ViewOptionsKwargs]) → Deferred[ViewResult]

Executes a View query against the bucket.

Deprecated since version 4.6.0: Views are deprecated in Couchbase Server 7.0+, and will be removed from a future server version. Views are not compatible with the Magma storage engine. Instead of views, use indexes and queries using the Index Service (GSI) and the Query Service (SQL++).

Note

The query is sent when this is called, and the Deferred fires once the core has buffered the response, so iterating the ViewResult does not block the reactor.

See also

Parameters:
  • design_doc (str) – The name of the design document containing the view to execute.

  • view_name (str) – The name of the view to execute.

  • view_options (ViewOptions) – Optional parameters for the view query operation.

  • **kwargs – keyword arguments that can be used in place or to override provided ViewOptions

Returns:

An instance of a ViewResult which provides access to iterate over the query results and access metadata about the query.

Return type:

Deferred[ViewResult]

txcouchbase.bucket.TxBucket

alias of Bucket