PostgrSQL binding spec

要设置与 PostgreSQL相关的 绑定,需要创建类型 的组件。 See on how to create and apply a binding configuration.

Warning

以上示例将密钥明文存储, 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

Both methods also support connection pool configuration variables:

  • 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

字段名为 ttlInSeconds

  • query
  • 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).

请求

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

The query 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. }

响应

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.

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