Open
Description
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?
Metadata
Metadata
Assignees
Labels
No labels