Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Django 5.1 PostgreSQL connection pools to env.db_url #530

Open
federicobond opened this issue Aug 16, 2024 · 0 comments
Open

Comments

@federicobond
Copy link

From the Django 5.1 release notes:

Django 5.1 also introduces connection pool support for PostgreSQL. As the time to establish a new connection can be relatively long, keeping connections open can reduce latency.

To use a connection pool with psycopg, you can set the "pool" option inside OPTIONS to be a dict to be passed to ConnectionPool, or to True to use the ConnectionPool defaults:

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        # ...
        "OPTIONS": {
            "pool": {
                "min_size": 2,
                "max_size": 4,
                "timeout": 10,
            }
        },
    },
}

https://docs.djangoproject.com/en/5.1/releases/5.1/#postgresql-connection-pools

The format does not lend itself well to be passed as query params in the DATABASE_URL.

Perhaps they can be passed in a new extra_options argument?

env.db_url(extra_options={
  "pool": {"min_size": 2, "max_size": 4, "timeout": 10}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant