Skip to content

Commit 722cbee

Browse files
committed
Add a few links to the docs
Now that I'm back online. :)
1 parent 6d8dcc0 commit 722cbee

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

postgres.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@
3939
Bind Parameters
4040
+++++++++++++++
4141
42-
In case you're not familiar with bind parameters in DB-API 2.0, the basic idea
43-
is that you put ``%(foo)s`` in your SQL strings, and then pass in a second
42+
In case you're not familiar with bind parameters in `DB-API 2.0`_, the basic
43+
idea is that you put ``%(foo)s`` in your SQL strings, and then pass in a second
4444
argument, a :py:class:`dict`, containing parameters that :py:mod:`psycopg2` (as
4545
an implementation of DB-API 2.0) will bind to the query in a way that is safe
46-
against SQL injection. (This is inspired by old-style Python string formatting,
47-
but it is not the same.)
46+
against `SQL injection`_. (This is inspired by old-style Python string
47+
formatting, but it is not the same.)
4848
4949
>>> db.one("SELECT * FROM foo WHERE bar=%(bar)s", {"bar": "baz"})
5050
{'bar': 'baz'}
@@ -57,15 +57,17 @@
5757
Context Managers
5858
++++++++++++++++
5959
60-
Eighty percent of your database usage should be covered by the simple API
61-
above. For the other 20%, :py:mod:`postgres` provides context managers for
62-
working at increasingly lower levels of abstraction. The lowest level of
63-
abstraction in :py:mod:`postgres` is a :py:mod:`psycopg2` connection pool that
64-
we configure and manage for you. Everything in :py:mod:`postgres`, both the
65-
simple API and the context managers, uses this connection pool.
66-
67-
Here's how to work directly with a `psycogpg2 cursor
68-
<http://initd.org/psycopg/docs/cursor.html>`_ while still taking advantage of
60+
Eighty percent of your database usage should be covered by the simple
61+
:py:meth:`~postgres.Postgres.run`, :py:meth:`~postgres.Postgres.one`,
62+
:py:meth:`~postgres.Postgres.rows` API introduced above. For the other 20%,
63+
:py:mod:`postgres` provides context managers for working at increasingly lower
64+
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.
68+
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
6971
connection pooling:
7072
7173
>>> with db.get_cursor() as cursor:
@@ -124,6 +126,8 @@
124126
.. _psycopg2: http://initd.org/psycopg/
125127
.. _GitHub: https://github.com/gittip/postgres
126128
.. _PyPI: https://pypi.python.org/pypi/postgres
129+
.. _DB-API 2.0: http://www.python.org/dev/peps/pep-0249/
130+
.. _SQL injection: http://en.wikipedia.org/wiki/SQL_injection
127131
128132
"""
129133
from __future__ import unicode_literals

0 commit comments

Comments
 (0)