Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve pool documentation examples #491

Merged
merged 5 commits into from Jul 18, 2020
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion asyncpg/pool.py
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("""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to change either docstring quotes to make this valid syntax. Also, please indent. Thanks!

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