PolarDB for MySQL & PostgreSQL
Configure PolarDB as a DataWorks data source to integrate MySQL or PostgreSQL workloads into your data pipelines. The polardb data source type supports two connection modes: Instance mode (recommended for PolarDB clusters within Alibaba Cloud) and Connection string mode (for direct host-based connections).
Choose a connection mode
| Mode | When to use |
|---|---|
| Instance mode | Connecting to a PolarDB cluster by cluster ID. Supports both same-account and cross-account access. |
| Connection string mode | Connecting via a direct host address, such as a public endpoint or a custom network entry point. |
Instance mode
Same-account access
Connect to a PolarDB cluster in the current Alibaba Cloud account by specifying the cluster ID and region.
Minimal configuration:
{
"envType": "Prod",
"dbType": "mysql",
"clusterId": "pc-xxxxxxxxx",
"regionId": "cn-shanghai",
"database": "db",
"username": "aliyun",
"password": "****",
"securityProtocol": "authTypeNone"
}
To connect to a PostgreSQL engine, set "dbType": "postgresql".
Parameters:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
regionId |
String | Yes | The ID of the region where the PolarDB cluster is deployed. | cn-shanghai |
clusterId |
String | Yes | The ID of the PolarDB cluster. | pc-2ze82jv51re2990g5 |
database |
String | Yes | The name of the database. | mysql_database |
dbType |
String | Yes | The compute engine type. Valid values: mysql, postgresql. |
mysql |
username |
String | Yes | The database username. | aliyun |
password |
String | Yes | The database password. | — |
envType |
String | Yes | The environment type. Valid values: Dev, Prod. |
Prod |
securityProtocol |
String | No | The authentication type. Valid values: authTypeNone (no authentication), authTypeSsl (SSL authentication enabled). |
authTypeNone |
truststoreFile |
String | No | The ID of the truststore file. | 1 |
truststorePassword |
String | No | The password of the truststore file. | — |
keystoreFile |
String | No | The ID of the keystore file. | 2 |
keystorePassword |
String | No | The password of the keystore file. | — |
readOnlyDBInstance |
String | No | The address of the secondary database. | pc-2ze82jv51re2990g5.rwlb.rds.aliyuncs.com:3306 |
Cross-account access
Connect to a PolarDB cluster owned by a different Alibaba Cloud account using RAM role delegation.
Minimal configuration:
{
"envType": "Prod",
"dbType": "postgresql",
"clusterId": "pc-xxxxxxxxx",
"regionId": "cn-shanghai",
"database": "db",
"username": "aliyun",
"password": "****",
"crossAccountOwnerId": "1234567890",
"crossAccountRoleName": "my_ram_role",
"securityProtocol": "authTypeNone"
}
Parameters:
All parameters from Same-account access apply, plus the following required cross-account parameters:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
crossAccountOwnerId |
String | Yes | The ID of the Alibaba Cloud account that owns the PolarDB cluster. | 1234567890 |
crossAccountRoleName |
String | Yes | The name of the RAM role assumed by another Alibaba Cloud account. | my_ram_role |
Connection string mode
Connect to PolarDB using a direct host address and port. This mode does not require a cluster ID.
Minimal configuration:
{
"envType": "Prod",
"dbType": "mysql",
"address": [
{
"host": "127.0.0.1",
"port": 5432
}
],
"database": "db",
"username": "aliyun",
"password": "****"
}
Parameters:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
dbType |
String | Yes | The compute engine type. Valid values: mysql, postgresql. |
mysql |
address |
Array | Yes | One or more host and port pairs. Each item must include host and port. |
See above |
database |
String | Yes | The name of the database. | db |
username |
String | Yes | The database username. | aliyun |
password |
String | Yes | The database password. | — |
envType |
String | Yes | The environment type. Valid values: Dev, Prod. |
Prod |
securityProtocol |
String | No | The authentication type. Valid values: authTypeNone (no authentication), authTypeSsl (SSL authentication enabled). |
authTypeNone |
truststoreFile |
String | No | The ID of the truststore file. | 1 |
truststorePassword |
String | No | The password of the truststore file. | — |
keystoreFile |
String | No | The ID of the keystore file. | 2 |
keystorePassword |
String | No | The password of the keystore file. | — |
properties |
JSON object | No | Additional JDBC driver properties. | {"useSSL": "false"} |
SSL authentication
Control encryption for the database connection using the securityProtocol parameter.
| Value | Behavior |
|---|---|
authTypeNone |
No authentication type is specified. |
authTypeSsl |
SSL authentication is enabled. |
When securityProtocol is set to authTypeSsl, provide the truststore and keystore file IDs using the truststoreFile and keystoreFile parameters.