For the complete documentation index, see llms.txt. This page is also available as Markdown.

❖ AlloyDB

This page describes how to integrate with your AlloyDB database.

SDV Enterprise Bundle. This feature is available as part of the AI Connectors Bundle, an optional add-on to SDV Enterprise. For more information, please visit the AI Connectors Bundle page.

Installation

To use this feature, please make sure you have installed the bundle with the optional db-alloydb dependency. For more information, see the SDV Enterprise Installation docs.

pip install sdv-installer --upgrade
sdv-installer install --package bundle-ai-connectors --options db-alloydb

Connector

Create a connector object that interacts with your AlloyDB database.

from sdv.io.database import AlloyDBConnector

connector = AlloyDBConnector()

Parameters (None)

Output An AlloyDBConnector object that you can use to import data and metadata

Config File

Create a YAML file that corresponds to the database to connect to. You will need separate config files for your source dataset (for importing training data) and a destination dataset (for exporting synthetic data).

The config file has the following structure:

Parameters:

connection: This section defines the database tables you want to connect to. It is common to all Google-native databases.

  • (required) database_name: A top-level logical container for data and database objects within a database system.

  • (required) schema_name: A named logical grouping of database objects within a database, used for organization and access control.

auth: This section provides information about your identity, which is required to connect to the database. It is common to all Google-native databases.

  • (required) json_credentials_filepath: A string with the file that contains the credentials. This can be downloaded for user or service accounts via Google's interface. Follow the instructions in these docs to select your account, add a key, and download the JSON file. (If you need help with this step, please contact your database admin.)

options.AlloyDBConnector: This section includes information that is specific for AlloyDB databases.

  • (required) region: The Google Cloud region where the AlloyDB cluster is deployed (for example us-central1 or europe-west1).

  • (required) cluster: The AlloyDB cluster that contains the database instances. A cluster is the top-level AlloyDB resource that manages storage, backups, and instances.

  • (required) instance_id: The unique name of the specific AlloyDB database instance you want to connect to.

  • ip_type: Specifies which network IP type the connector should use when connecting to AlloyDB. Common values are PRIVATE or PUBLIC.

    • (default): PRIVATE

Setting Your Config File

Use the set_import_config and set_export_config functions to add your config YAML file to your connector.

Use the connector to create metadata, import a subset of training data, and export synthetic data. For more information, see the Usage API.

FAQ

Which permissions are needed for importing and exporting?

Importing data requires read access and exporting data requires write access.

Please note that your Python client will also need the base permissions for roles/alloydb.client and roles/alloydb.viewer. These roles grant the following permissions: alloydb.clusters.generateClientCertificate, alloydb.clusters.get, alloydb.instances.connect, alloydb.instances.get, alloydb.users.login, alloydb.instances.executeSql

If you are using a Google Cloud API, you will also need the Service Usage Consumer permissions (roles/serviceusage.serviceUsageConsumer). To login with a service account, you will need to enable IAM authentication with the flag alloydb.iam_authentication (this is not enabled by default).

For more information, see AlloyDB documentation.

Last updated