Registry / gcp / google-cloud-alloydb

google-cloud-alloydb

JSON →
library0.11.1pypypi✓ verified 24d ago

The `google-cloud-alloydb` library is the official Python client for interacting with Google Cloud AlloyDB, a fully managed, PostgreSQL-compatible database service. It provides programmatic access to manage clusters, instances, backups, and users within AlloyDB. The current version is 0.9.0, indicating it is still in active development, with releases typically tied to updates in the underlying Google Cloud API.

pip install google-cloud-alloydb
INSTALL
IMPORT
SIG · GOOGLE-CLOUD-ALLOY
G
google-cloud-alloydb
gcppythonv0.11.1
Install
5.8s avg
Import
Disk
76MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.11.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 77.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.8s · import 0.000s · 75MB
76MB installed
● package 76MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AlloyDBClient
from google.cloud.alloydb import AlloyDBClient
from google.cloud.alloydb import AlloyDBClient

This quickstart initializes an AlloyDB client and lists all clusters within a specified Google Cloud project and region. AlloyDB is a regional service, so specifying the `location` is critical for most operations. Ensure `GOOGLE_CLOUD_PROJECT` environment variable is set or replace the placeholder. Authentication is typically handled automatically via `gcloud auth application-default login` or by setting `GOOGLE_APPLICATION_CREDENTIALS`.

import os from google.cloud.alloydb_v1 import AlloyDBClient project_id = os.environ.get("GOOGLE_CLOUD_PROJECT", "your-project-id") location = "us-central1" # Replace with your desired region if project_id == "your-project-id": print("Please set the GOOGLE_CLOUD_PROJECT environment variable or replace 'your-project-id' in the code.") exit() client = AlloyDBClient() parent = f"projects/{project_id}/locations/{location}" try: # Listing clusters within a specific region. AlloyDB is a regional service. print(f"Fetching AlloyDB Clusters in {location} for project {project_id}...") clusters_iterator = client.list_clusters(parent=parent) found_clusters = [] for cluster in clusters_iterator: found_clusters.append(cluster) print(f"- Cluster: {cluster.name} (State: {cluster.state.name}, Type: {cluster.cluster_type.name})") if not found_clusters: print(" No clusters found in this location for the specified project.") except Exception as e: print(f"\nAn error occurred: {e}") print("Ensure you have authenticated (e.g., via `gcloud auth application-default login`) ") print("and possess the 'AlloyDB Admin' role or equivalent permissions on the project.") print("Also, verify that the GOOGLE_CLOUD_PROJECT environment variable and location are correct.")
Debug
Known issues
gotchaGoogle Cloud client libraries require proper authentication. Operations will fail with permission errors if your environment is not authenticated or lacks the necessary IAM roles (e.g., `AlloyDB Admin`).
fix
Authenticate your environment using `gcloud auth application-default login` or by setting the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to a service account key file path. Grant the principal the 'AlloyDB Admin' role or a more granular custom role.
affects: All versions
gotchaAlloyDB is a regional service. Most operations (e.g., creating/listing clusters or instances) require you to specify a `location` within the request payload or as part of a parent resource name (e.g., `projects/{project_id}/locations/{location}`). Failing to do so will result in errors or incorrect resource targeting.
fix
Always provide the correct region/location identifier when interacting with AlloyDB resources. For client methods, this is often done via a `parent` argument formatted as `projects/{project_id}/locations/{location}`.
affects: All versions
breakingThe `google-cloud-alloydb` library is currently in version `0.x.y`. While Google strives for stability, this versioning scheme indicates that breaking changes to the API surface may occur in minor versions before the library reaches `1.0.0`.
fix
Pin your dependency to an exact version (e.g., `google-cloud-alloydb==0.9.0`) to avoid unexpected breakages when deploying to production. Regularly review release notes for new versions before upgrading.
affects: 0.1.0 - 0.9.0
gotchaThe library provides both synchronous (`AlloyDBClient`) and asynchronous (`AlloyDBAsyncClient`) clients. Ensure you use the correct client for your application's concurrency model. Mixing them or attempting to `await` on synchronous methods will lead to `TypeError` or `RuntimeError`.
fix
For `async`/`await` patterns, import and instantiate `AlloyDBAsyncClient`. For traditional blocking calls, use `AlloyDBClient`. Do not attempt to call synchronous methods with `await` or vice-versa.
affects: All versions
gotchaThe `AlloyDBClient` and `AlloyDBAsyncClient` classes are not directly available under `google.cloud.alloydb_v1`. They are typically located in a deeper submodule specific to the service client, following the pattern `google.cloud.<service>_v1.services.<service_name>.client`.
fix
Adjust your import statement to `from google.cloud.alloydb_v1.services.alloydb.client import AlloyDBClient` (and similarly for `AlloyDBAsyncClient` if using the asynchronous client).
affects: All versions
Upgrade
Version history
0.11.1latest on PyPI · released Aug 24, 2026
Audit
Dependencies
google-api-corerequiredCore library for Google API clients, handling authentication, retries, and request formatting.
Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
google-cloud-alloydb — pip install google-cloud-alloydb · libregistry