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
user=dapr password=secret host=dapr.example.com port=5432 dbname=dapr sslmode=verify-ca
Example URL
pool_min_conns
: integer 0 or greaterpool_max_conns
: integer greater than 0pool_max_conn_idle_time
: duration stringpool_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
{
"operation": "exec",
"metadata": {
"sql": "INSERT INTO foo (id, c1, ts) VALUES (1, 'demo', '2020-09-24T11:45:05Z07:00')"
}
}
Response
The operation is used for SELECT
statements, which returns the metadata along with data in a form of an array of row values.
{
"metadata": {
"sql": "SELECT * FROM foo WHERE id < 3"
}
}
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
{
"operation": "close"
}
Last modified September 17, 2021 : Merge pull request #1757 from georgestevens99/1440SecretKeyRefExplanation (620a5f8)