Skip to content

Client Reference

Datastore client connection manager for the Google Cloud Datastore ODM.

This module provides a singleton pattern to ensure that only one instance of the google.cloud.datastore.Client is created per GCP project and database. This prevents connection overhead and memory leaks.

get_client(project=None, database=None)

Retrieve the global Google Cloud Datastore client instance.

If the client for the requested project/database has not been initialized yet, this function will create a new instance. If project or database is None, it automatically infers the defaults from the environment.

Parameters:

Name Type Description Default
project Optional[str]

The specific GCP project ID to connect to.

None
database Optional[str]

The specific Datastore database name to connect to.

None

Returns:

Type Description
Client

datastore.Client: The active Datastore client connection.