PostgrSQL binding spec
Warning
The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described here.
The PostgrSQL binding uses internally so the 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_lifetime
: duration stringpool_health_check_period
: duration string
exec
query
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"