Skip to content

Commit 7c69bcd

Browse files
committed
Preen docs
1 parent 722cbee commit 7c69bcd

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

postgres.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
>>> db.one("SELECT * FROM foo ORDER BY bar")
2929
{'bar': 'baz'}
3030
>>> db.one("SELECT * FROM foo WHERE bar='blam'")
31-
None
31+
>>> # None
3232
3333
Use :py:meth:`~postgres.Postgres.rows` to fetch all results:
3434
@@ -62,12 +62,13 @@
6262
:py:meth:`~postgres.Postgres.rows` API introduced above. For the other 20%,
6363
:py:mod:`postgres` provides context managers for working at increasingly lower
6464
levels of abstraction. The lowest level of abstraction in :py:mod:`postgres` is
65-
a :py:mod:`psycopg2` connection pool that we configure and manage for you.
66-
Everything in :py:mod:`postgres`, both the simple API and the context managers,
67-
uses this connection pool.
65+
a :py:mod:`psycopg2` `connection pool
66+
<http://initd.org/psycopg/docs/pool.html>`_ that we configure and manage for
67+
you. Everything in :py:mod:`postgres`, both the simple API and the context
68+
managers, uses this connection pool.
6869
69-
Here's how to work directly with a :py:mod:`psycogpg2.cursor` (`docs
70-
<http://initd.org/psycopg/docs/cursor.html>`_) while still taking advantage of
70+
Here's how to work directly with a :py:mod:`psycogpg2` `cursor
71+
<http://initd.org/psycopg/docs/cursor.html>`_ while still taking advantage of
7172
connection pooling:
7273
7374
>>> with db.get_cursor() as cursor:
@@ -90,7 +91,7 @@
9091
[{'bar': 'baz'}, {'bar': 'blam'}, {'bar': 'buz'}]
9192
9293
Note that other calls won't see the changes on your transaction until the end
93-
of your code block, when the context manager commits the transaction::
94+
of your code block, when the context manager commits the transaction for you::
9495
9596
>>> with db.get_transaction() as txn:
9697
... txn.execute("INSERT INTO foo VALUES ('blam')")
@@ -102,11 +103,11 @@
102103
103104
The :py:func:`~postgres.Postgres.get_transaction` manager gives you a cursor
104105
with :py:attr:`autocommit` turned off on its connection. If the block under
105-
management raises, the connection is rolled back. Otherwise it's committed.
106-
Use this when you want a series of statements to be part of one transaction,
107-
but you don't need fine-grained control over the transaction. For fine-grained
108-
control, use :py:func:`~postgres.Postgres.get_connection` to get a connection
109-
straight from the connection pool:
106+
management raises an exception, the connection is rolled back. Otherwise it's
107+
committed. Use this when you want a series of statements to be part of one
108+
transaction, but you don't need fine-grained control over the transaction. For
109+
fine-grained control, use :py:func:`~postgres.Postgres.get_connection` to get a
110+
connection straight from the connection pool:
110111
111112
>>> with db.get_connection() as connection:
112113
... cursor = connection.cursor()
@@ -118,6 +119,8 @@
118119
A connection gotten in this way will have :py:attr:`autocommit` turned off, and
119120
it'll never be implicitly committed otherwise. It'll actually be rolled back
120121
when you're done with it, so it's up to you to explicitly commit as needed.
122+
This is the lowest-level abstraction that :py:mod:`postgres` provides,
123+
basically just a pre-configured connection pool from :py:mod:`psycopg2`.
121124
122125
123126
API

0 commit comments

Comments
 (0)