Skip to content

Commit eee2181

Browse files
authored
docs: fix snapshot usage (#291)
Fix a wrong keyword argument `key_set`. Correctly, it is `keyset`, and the value must be a instance of `spanner.KeySet()`. `snapshot.read()` and `snapshot.execute_sql()` returns an iterable. It does not have `rows` attribute.
1 parent baa02ee commit eee2181

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/snapshot-usage.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ Read Table Data
6565

6666
To read data for selected rows from a table in the database, call
6767
:meth:`~google.cloud.spanner_v1.snapshot.Snapshot.read` which will return
68-
all rows specified in ``key_set``, or fail if the result set is too large,
68+
all rows specified in ``keyset``, or fail if the result set is too large,
6969

7070
.. code:: python
7171
7272
with database.snapshot() as snapshot:
7373
result = snapshot.read(
7474
table='table-name', columns=['first_name', 'last_name', 'age'],
75-
key_set=['phred@example.com', 'bharney@example.com'])
75+
keyset=spanner.KeySet([['phred@example.com'], ['bharney@example.com']]))
7676
77-
for row in result.rows:
77+
for row in result:
7878
print(row)
7979
8080
.. note::
@@ -100,7 +100,7 @@ result set is too large,
100100
'WHERE p.employee_id == e.employee_id')
101101
result = snapshot.execute_sql(QUERY)
102102
103-
for row in list(result):
103+
for row in result:
104104
print(row)
105105
106106
.. note::

0 commit comments

Comments
 (0)