Skip to content

Commit c37b7c4

Browse files
committed
Merge commit '09db2d3b922d2562a4369dd4f713b0465e03d3f8'
2 parents 729f587 + 09db2d3 commit c37b7c4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

postgres.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,15 @@ def one(self, sql, parameters=None, strict=None):
300300
:raises: :py:exc:`~postgres.TooFew` or :py:exc:`~postgres.TooMany`
301301
302302
By default, :py:attr:`strict` ends up evaluating to :py:class:`True`,
303-
in which case we raise :py:exc:`~postgres.TooFew` or
304-
:py:exc:`~postgres.TooMany` if the number of rows returned isn't
305-
exactly one. You can override this behavior per-call with the
306-
:py:attr:`strict` argument here, or globally by passing
307-
:py:attr:`strict_one` to the :py:class:`~postgres.Postgres`
308-
constructor. If you use both, the :py:attr:`strict` argument here wins.
303+
in which case we raise :py:exc:`postgres.TooFew` or
304+
:py:exc:`postgres.TooMany` if the number of rows returned isn't exactly
305+
one (both are subclasses of :py:exc:`postgres.NotOne`). You can
306+
override this behavior per-call with the :py:attr:`strict` argument
307+
here, or globally by passing :py:attr:`strict_one` to the
308+
:py:class:`~postgres.Postgres` constructor. If you use both, the
309+
:py:attr:`strict` argument here wins. If you pass :py:class:`False`
310+
for :py:attr:`strict`, then we return :py:class:`None` if there are no
311+
results, and the first if there is more than one.
309312
310313
>>> row = db.one("SELECT * FROM foo WHERE bar='baz'")
311314
>>> print(row["bar"])
@@ -333,7 +336,7 @@ def one(self, sql, parameters=None, strict=None):
333336
return cursor.fetchone()
334337

335338
def all(self, sql, parameters=None):
336-
"""Execute a query and return all resulting rows.
339+
"""Execute a query and return all results.
337340
338341
:param unicode sql: the SQL statement to execute
339342
:param parameters: the bind parameters for the SQL statement

0 commit comments

Comments
 (0)