MagicStack / MagicStack/asyncpg
Is it possible to specify multi hosts dsn for connection pool?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.1k
- Forks
- 468
- PR merge metrics
- No merged PRs in 30d
Description
Is it possible to connect to several hosts (one master and replicas) from ConnectionPool (interface like libpq provides)?
I mean the following: https://www.postgresql.org/docs/current/static/libpq-connect.html
```
# Read sessions
postgresql://host1:123,host2:456/somedb?target_session_attrs=any
# Read-write sessions
postgresql://host1:123,host2:456/somedb?target_session_attrs=read-write
```
I enumerate all postgresql hosts and in target_session_attrs parameter specify `read-write` if i need master.
Or i should create separate connection pools for master & replicas servers?
How that functionality (switching between hosts depending on target_session_attrs attrs, re-connecting on master switch) can be implemented in asyncpg?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing asyncpg's ConnectionPool interface and the linked PostgreSQL libpq documentation for multi-host DSNs and target_session_attrs. The issue names no source files or tests; done would be clear support for multi-host selection and reconnection, or a documented alternative using separate pools.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100