PostgreSQL binding spec

To setup PostgreSQL binding create a component of type . See on how to create and apply a binding configuration.

Warning

The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described .

The PostgreSQL binding uses pgx connection pool internally so the url parameter can be any valid connection string, either in a DSN or URL format:

Example DSN

  1. user=dapr password=secret host=dapr.example.com port=5432 dbname=dapr sslmode=verify-ca

Example URL

  • pool_min_conns: integer 0 or greater
  • pool_max_conns: integer greater than 0
  • pool_max_conn_idle_time: duration string
  • pool_health_check_period: duration string

This component supports output binding with the following operations:

  • exec
  • close

The exec operation can be used for DDL operations (like table creation), as well as INSERT, UPDATE, DELETE operations which return only metadata (e.g. number of affected rows).

Request

  1. {
  2. "operation": "exec",
  3. "metadata": {
  4. "sql": "INSERT INTO foo (id, c1, ts) VALUES (1, 'demo', '2020-09-24T11:45:05Z07:00')"
  5. }
  6. }

Response

The operation is used for SELECT statements, which returns the metadata along with data in a form of an array of row values.

  1. {
  2. "metadata": {
  3. "sql": "SELECT * FROM foo WHERE id < 3"
  4. }
  5. }

Response

Finally, the close operation can be used to explicitly close the DB connection and return it to the pool. This operation doesn’t have any response.

Request

  1. {
  2. "operation": "close"
  3. }

Last modified November 12, 2021 : Merge pull request #1949 from willtsai/az-staticwebapp-versioning (c40e456)