Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion asyncpg/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,14 +798,27 @@ def create_pool(dsn=None, *,

Can be used either with an ``async with`` block:

.. code-block:: python

async with asyncpg.create_pool(user='postgres',
command_timeout=60) as pool:
await pool.fetch('SELECT 1')

Or to perform multiple operations on a single connection:

.. code-block:: python

async with asyncpg.create_pool(user='postgres',
command_timeout=60) as pool:
async with pool.acquire() as con:
await con.execute('''
CREATE TABLE names (
id serial PRIMARY KEY,
name VARCHAR (255) NOT NULL)
''')
await con.fetch('SELECT 1')

Or directly with ``await``:
Or directly with ``await`` (not recommended):

.. code-block:: python

Expand Down