PostgreSQL

Updated at:

Configure a PostgreSQL data source in DataWorks using instance mode or connection string mode.

  • Data source type: postgresql

  • Supported configuration modes (ConnectionPropertiesMode): InstanceMode, UrlMode

Instance mode (current Alibaba Cloud account)

Use instance mode when your PostgreSQL instance runs on Alibaba Cloud under the same account as your DataWorks workspace. DataWorks resolves the connection endpoint from the instance ID and region.

Parameters

Parameter Type Required Example Description
regionId String Yes cn-shanghai The region where the instance resides.
instanceId String Yes pgm-xxxxxxxxx The instance ID.
database String Yes postgresql_database The database name.
username String Yes xxxxx The database username.
password String Yes xxxxx The database password.
envType String Yes Dev The environment type. Valid values: Dev (development environment), Prod (production environment).
securityProtocol String No AuthTypeNone The authentication type. Valid values: AuthTypeNone (no authentication type is specified), AuthTypeSsl (SSL authentication is enabled).
truststoreFile String No 661605759515426 The ID of the truststore file.
keystoreFile String No 661605759515426 The ID of the keystore file.
keyFile String No 661605759515426 The ID of the private key file.
clientPassword String No abc The password of the private key.
readOnlyDBInstance String No pgr-uf65l3bwae8w8r35 The ID of the secondary instance.

Example

{
    "envType": "Prod",
    "instanceId": "pgm-xxxxxxxxx",
    "regionId": "cn-shanghai",
    "database": "db",
    "username": "aliyun",
    "password": "xxx",
    "securityProtocol": "AuthTypeNone"
}

Instance mode (another Alibaba Cloud account)

Use cross-account instance mode when your PostgreSQL instance belongs to a different Alibaba Cloud account. This requires a RAM role that grants your DataWorks workspace access to the instance in the target account.

Parameters

Parameter Type Required Example Description
regionId String Yes cn-shanghai The region where the instance resides.
instanceId String Yes pgm-xxxxxxxxx The instance ID.
database String Yes postgresql_database The database name.
username String Yes xxxxx The database username.
password String Yes xxxxx The database password.
crossAccountOwnerId String Yes 1 The ID of another Alibaba Cloud account.
crossAccountRoleName String Yes postgresql-role The name of the RAM role assumed for cross-account access.
envType String Yes Dev The environment type. Valid values: Dev (development environment), Prod (production environment).
securityProtocol String No AuthTypeNone The authentication type. Valid values: AuthTypeNone (no authentication type is specified), AuthTypeSsl (SSL authentication is enabled).
truststoreFile String No 661605759515426 The ID of the truststore file.
keystoreFile String No 661605759515426 The ID of the keystore file.
keyFile String No 661605759515426 The ID of the private key file.
clientPassword String No abc The password of the private key.
readOnlyDBInstance String No pgr-uf65l3bwae8w8r35 The ID of the secondary instance.

Example

{
    "envType": "Prod",
    "instanceId": "pgm-xxxxxxxxx",
    "regionId": "cn-shanghai",
    "database": "db",
    "username": "aliyun",
    "password": "xxx",
    "securityProtocol": "AuthTypeNone",
    "crossAccountOwnerId": "1234567890",
    "crossAccountRoleName": "my_ram_role"
}

Connection string mode

Use connection string mode to connect to a PostgreSQL instance by specifying the host and port directly. This mode supports self-managed PostgreSQL instances and cloud instances not accessible by instance ID.

Parameters

Parameter Type Required Example Description
address Array Yes [{"host": "127.0.0.1", "port": 5432}] One or more host-and-port pairs for the database endpoint.
database String Yes postgresql_database The database name.
username String Yes xxxxx The database username.
password String Yes xxxxx The database password.
envType String Yes Dev The environment type. Valid values: Dev (development environment), Prod (production environment).
securityProtocol String No AuthTypeNone The authentication type. Valid values: AuthTypeNone (no authentication type is specified), AuthTypeSsl (SSL authentication is enabled).
truststoreFile String No 661605759515426 The ID of the truststore file.
keystoreFile String No 661605759515426 The ID of the keystore file.
keyFile String No 661605759515426 The ID of the private key file.
clientPassword String No abc The password of the private key.
properties JSON object No {"useSSL": "false"} The properties of the driver.

Example

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