AnalyticDB for PostgreSQL
Configure an AnalyticDB for PostgreSQL data source in DataWorks to connect your analytics database to data integration workflows.
Data source type:
analyticdb_for_postgresqlSupported 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
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
regionId | String | Yes | The region where the AnalyticDB for PostgreSQL instance resides. | cn-shanghai |
instanceId | String | Yes | The ID of the AnalyticDB for PostgreSQL instance. | gp-wz90k6goz2i63d8m1 |
database | String | Yes | The name of the database to connect to. | database_demo |
username | String | Yes | The username for database access. | xxxxx |
password | String | Yes | The password for database access. | xxxxx |
envType | String | Yes | The 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
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
regionId | String | Yes | The region where the AnalyticDB for PostgreSQL instance resides. | cn-shanghai |
instanceId | String | Yes | The ID of the AnalyticDB for PostgreSQL instance. | gp-wz90k6goz2i63d8m1 |
database | String | Yes | The name of the database to connect to. | database_demo |
username | String | Yes | The username for database access. | xxxxx |
password | String | Yes | The password for database access. | xxxxx |
crossAccountOwnerId | String | Yes | The ID of the Alibaba Cloud account that owns the instance. | 1577495724967111 |
crossAccountRoleName | String | Yes | The name of the RAM role to assume for cross-account access. | dw-ds2.0-role |
envType | String | Yes | The 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
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
database | String | Yes | The name of the database to connect to. | database_demo |
username | String | Yes | The username for database access. | xxxxx |
password | String | Yes | The password for database access. | xxxxx |
address | JSON array | Yes | The 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}] |
properties | JSON object | No | Advanced parameters for the JDBC connection, specified as key-value pairs. | {"connectTimeout": "2000"} |
envType | String | Yes | The 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"
}