Skip to content

Commit d0aa5e7

Browse files
committed
Take unicode markers out of docstrings
Python 3 doesn't have them, and we want to be Python 3.
1 parent 5f735ec commit d0aa5e7

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

postgres/__init__.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,20 @@
3232
Use :py:meth:`~postgres.Postgres.all` to run SQL and fetch all results:
3333
3434
>>> db.all("SELECT * FROM foo ORDER BY bar")
35-
[Record(bar=u'bit', baz=537), Record(bar=u'buz', baz=42)]
35+
[Record(bar='bit', baz=537), Record(bar='buz', baz=42)]
3636
3737
Use :py:meth:`~postgres.Postgres.one_or_zero` to run SQL and fetch one result
3838
or :py:class:`None`:
3939
4040
>>> db.one_or_zero("SELECT * FROM foo WHERE bar='buz'")
41-
Record(bar=u'buz', baz=42)
41+
Record(bar='buz', baz=42)
4242
>>> db.one_or_zero("SELECT * FROM foo WHERE bar='blam'")
4343
44-
If your query returns one column then you get a list of values instead of
45-
Records:
44+
If your queries return one column then you get just the value or a list of
45+
values instead of a Record or list of Records:
4646
47+
>>> db.one_or_zero("SELECT baz FROM foo WHERE bar='buz'")
48+
42
4749
>>> db.all("SELECT baz FROM foo ORDER BY bar")
4850
[537, 42]
4951
@@ -59,7 +61,7 @@
5961
formatting, but it is not the same.)
6062
6163
>>> db.one_or_zero("SELECT * FROM foo WHERE bar=%(bar)s", {"bar": "buz"})
62-
Record(bar=u'buz', baz=42)
64+
Record(bar='buz', baz=42)
6365
6466
Never build SQL strings out of user input!
6567
@@ -89,7 +91,7 @@
8991
... txn.execute("SELECT * FROM foo ORDER BY bar")
9092
... txn.fetchall()
9193
...
92-
[Record(bar=u'bit', baz=537), Record(bar=u'blam', baz=None), Record(bar=u'buz', baz=42)]
94+
[Record(bar='bit', baz=537), Record(bar='blam', baz=None), Record(bar='buz', baz=42)]
9395
9496
Note that other calls won't see the changes on your transaction until the end
9597
of your code block, when the context manager commits the transaction for you::
@@ -99,9 +101,9 @@
99101
... txn.execute("INSERT INTO foo VALUES ('blam')")
100102
... db.all("SELECT * FROM foo ORDER BY bar")
101103
...
102-
[Record(bar=u'bit', baz=537), Record(bar=u'buz', baz=42)]
104+
[Record(bar='bit', baz=537), Record(bar='buz', baz=42)]
103105
>>> db.all("SELECT * FROM foo ORDER BY bar")
104-
[Record(bar=u'bit', baz=537), Record(bar=u'blam', baz=None), Record(bar=u'buz', baz=42)]
106+
[Record(bar='bit', baz=537), Record(bar='blam', baz=None), Record(bar='buz', baz=42)]
105107
106108
The :py:func:`~postgres.Postgres.get_transaction` manager gives you a cursor
107109
with :py:attr:`autocommit` turned off on its connection. If the block under
@@ -117,7 +119,7 @@
117119
... cursor.execute("SELECT * FROM foo ORDER BY bar")
118120
... cursor.fetchall()
119121
...
120-
[Record(bar=u'bit', baz=537), Record(bar=u'buz', baz=42)]
122+
[Record(bar='bit', baz=537), Record(bar='buz', baz=42)]
121123
122124
A connection gotten in this way will have :py:attr:`autocommit` turned off, and
123125
it'll never be implicitly committed otherwise. It'll actually be rolled back
@@ -342,13 +344,13 @@ def all(self, sql, parameters=None):
342344
:returns: :py:class:`list` of records or single values
343345
344346
>>> db.all("SELECT * FROM foo ORDER BY bar")
345-
[Record(bar=u'bit', baz=537), Record(bar=u'buz', baz=42)]
347+
[Record(bar='bit', baz=537), Record(bar='buz', baz=42)]
346348
347349
If the query results in a single column, we return a list of values
348350
rather than a list of records of values.
349351
350-
>>> db.all("SELECT bar FROM foo ORDER BY bar")
351-
['bit', 'buz']
352+
>>> db.all("SELECT baz FROM foo ORDER BY bar")
353+
[537, 42]
352354
353355
"""
354356
with self.get_transaction() as txn:
@@ -373,7 +375,7 @@ def one_or_zero(self, sql, parameters=None, zero=None):
373375
it may not exist yet.
374376
375377
>>> db.one_or_zero("SELECT * FROM foo WHERE bar='buz'")
376-
Record(bar=u'buz', baz=42)
378+
Record(bar='buz', baz=42)
377379
>>> row = db.one_or_zero("SELECT * FROM foo WHERE bar='blam'")
378380
>>> if row is None:
379381
... print("No blam yet.")
@@ -430,7 +432,7 @@ def get_transaction(self, *a, **kw):
430432
... txn.execute("SELECT * FROM foo")
431433
... txn.fetchall()
432434
...
433-
[Record(bar=u'buz', baz=42), Record(bar=u'bit', baz=537)]
435+
[Record(bar='buz', baz=42), Record(bar='bit', baz=537)]
434436
435437
"""
436438
return TransactionContextManager(self.pool, *a, **kw)
@@ -448,7 +450,7 @@ def get_connection(self):
448450
... cursor.execute("SELECT * FROM foo")
449451
... cursor.fetchall()
450452
...
451-
[Record(bar=u'buz', baz=42), Record(bar=u'bit', baz=537)]
453+
[Record(bar='buz', baz=42), Record(bar='bit', baz=537)]
452454
453455
"""
454456
return ConnectionContextManager(self.pool)

0 commit comments

Comments
 (0)