MagicStack / MagicStack/asyncpg
Share connections from a pool with different databases in the same PG server
未关闭
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 8.1k
- 派生
- 468
- PR 合并指标
- 30 天内没有已合并 PR
描述
When we are using TLS connections to a PG server the cost to keep opened multiple connections to different databases is high. So I'd like to implement database switching to share the connections from a pool with different databases.
pool = await asyncpg.create_pool(database='postgres')
async def handle(queries):
"""Handle incoming queries."""
results = defaultdict(list)
for dbname, dbqueries in queries.items():
async with pool.acquire() as connection:
connection.set_database(dbname) # I want this !!!
async with connection.transaction():
for query in dbqueries:
result = await connection.execute(query)
results[dbname].append(result)
Is it feasible with asyncpg?
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
检查 asyncpg 的池和连接入口点,然后核对 PostgreSQL 的连接和数据库语义。该 issue 未指定文件或测试;要视为完成,需要维护者确认的范围,以及一个用于在多个数据库之间共享池化连接的可复现验收案例。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- postgresql, python
- 领域
- databases
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 20/100