AnalyticDB for PostgreSQL

Updated at:

Configure an AnalyticDB for PostgreSQL data source in DataWorks to connect your analytics database to data integration workflows.

  • Data source type: analyticdb_for_postgresql

  • Supported configuration modes (`ConnectionPropertiesMode`):

    • Connection string mode (UrlMode)

    • Instance mode (InstanceMode) — current-account or cross-account

Current-account instance mode

Use this mode when the AnalyticDB for PostgreSQL instance belongs to the same Alibaba Cloud account as your DataWorks workspace.

Before you begin, ensure that you have:

  • The region ID of the instance (e.g., cn-shanghai)

  • The instance ID (e.g., gp-wz90k6goz2i63d8m1)

  • The database name, username, and password

  • The target environment: development (Dev) or production (Prod)

Parameters

ParameterTypeRequiredDescriptionExample
regionIdStringYesThe region where the AnalyticDB for PostgreSQL instance resides.cn-shanghai
instanceIdStringYesThe ID of the AnalyticDB for PostgreSQL instance.gp-wz90k6goz2i63d8m1
databaseStringYesThe name of the database to connect to.database_demo
usernameStringYesThe username for database access.xxxxx
passwordStringYesThe password for database access.xxxxx
envTypeStringYesThe environment type. Valid values: Dev (the development environment) and Prod (the production environment).Dev

Configuration example

{
    "database": "dw",
    "password": "***",
    "instanceId": "gp-bp1rfbt2u81dpqvu7",
    "regionId": "cn-hangzhou",
    "envType": "Prod",
    "username": "dw"
}

Cross-account instance mode

Use this mode when the AnalyticDB for PostgreSQL instance belongs to a different Alibaba Cloud account.

Before you begin, ensure that you have:

  • The region ID and instance ID of the target instance

  • The database name, username, and password

  • The Alibaba Cloud account ID of the instance owner

  • The name of the RAM role granted by the instance owner

  • The target environment: development (Dev) or production (Prod)

Parameters

ParameterTypeRequiredDescriptionExample
regionIdStringYesThe region where the AnalyticDB for PostgreSQL instance resides.cn-shanghai
instanceIdStringYesThe ID of the AnalyticDB for PostgreSQL instance.gp-wz90k6goz2i63d8m1
databaseStringYesThe name of the database to connect to.database_demo
usernameStringYesThe username for database access.xxxxx
passwordStringYesThe password for database access.xxxxx
crossAccountOwnerIdStringYesThe ID of the Alibaba Cloud account that owns the instance.1577495724967111
crossAccountRoleNameStringYesThe name of the RAM role to assume for cross-account access.dw-ds2.0-role
envTypeStringYesThe environment type. Valid values: Dev (the development environment) and Prod (the production environment).Dev

Configuration example

{
    "crossAccountOwnerId": "1853195337009715",
    "crossAccountRoleName": "dw-role",
    "database": "dw",
    "password": "***",
    "instanceId": "gp-uf64vbm15484j44gn",
    "regionId": "cn-shanghai",
    "envType": "Prod",
    "username": "dw"
}

Connection string mode

Use this mode when you need to connect directly via a host address and port.

Before you begin, ensure that you have:

  • The host address and port of the AnalyticDB for PostgreSQL instance

  • The database name, username, and password

  • The target environment: development (Dev) or production (Prod)

  • (Optional) Advanced JDBC connection parameters

Parameters

ParameterTypeRequiredDescriptionExample
databaseStringYesThe name of the database to connect to.database_demo
usernameStringYesThe username for database access.xxxxx
passwordStringYesThe password for database access.xxxxx
addressJSON arrayYesThe host address and port of the instance, specified as a JSON array containing a single host-port object.[{"host": "127.0.0.1", "port": 3306}]
propertiesJSON objectNoAdvanced parameters for the JDBC connection, specified as key-value pairs.{"connectTimeout": "2000"}
envTypeStringYesThe environment type. Valid values: Dev (the development environment) and Prod (the production environment).Dev

Configuration example

{
    "address": [
        {
            "host": "127.0.0.1",
            "port": 5432
        }
    ],
    "database": "db",
    "properties": {
        "connectTimeout": "2000"
    },
    "username": "aliyun",
    "password": "xxx",
    "envType": "Dev"
}