For PostgreSQL database clusters, connection pools can be used to allow a database to share its idle connections. The popular PostgreSQL connection pooling utility PgBouncer is used to provide this service. See here for more information about how and why to use PgBouncer connection pooling including details about the available transaction modes.
To add a new connection pool to a PostgreSQL database cluster, send a POST
request to /v2/databases/$DATABASE_ID/pools
specifying a name for the pool,
the user to connect with, the database to connect to, as well as its desired
size and transaction mode.
Name | Type | Required | Description | Default Value |
---|---|---|---|---|
database_cluster_uuid |
string | True | A unique identifier for a database cluster. | |
body |
JSON or IO[bytes] | True |
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
add_conn_pool_req = {
"name": "backend-pool",
"mode": "transaction",
"size": 10,
"db": "defaultdb",
"user": "doadmin"
}
add_conn_pool_resp = client.databases.add_connection_pool(database_cluster_uuid="9cc10173", body=add_conn_pool_req)
See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.