Closed ghuname closed 3 years ago
current not support
In example you have provided:
async def use_pool():
pool = await asynch.create_pool()
async with pool.acquire() as conn:
async with conn.cursor() as cursor:
await cursor.execute("SELECT 1")
ret = cursor.fetchone()
assert ret == (1,)
pool.close()
await pool.wait_closed()
where connection parameters should be specified (host, port, database...)?
If I understood correctly, I should create a global pool object and afterwards, whenever I want to query database, I should use:
async with pool.acquire() as conn:
async with conn.cursor() as cursor:
await cursor.execute("SELECT 1")
ret = cursor.fetchone()
Can you please confirm?
params pass in create_pool, the example use default params
Maybe you should update the example.
Let's say that I have cluster of 6 nodes. I would like to create a connection pool with 6 connections, one per each node.
Can I implement such behavior with asynch.create_pool()?