Skip to content

Commit

Permalink
docs: fix snapshot usage (googleapis#291)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kit494way authored Mar 25, 2021
1 parent baa02ee commit eee2181
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/snapshot-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ Read Table Data

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

.. code:: python
with database.snapshot() as snapshot:
result = snapshot.read(
table='table-name', columns=['first_name', 'last_name', 'age'],
key_set=['phred@example.com', 'bharney@example.com'])
keyset=spanner.KeySet([['phred@example.com'], ['bharney@example.com']]))
for row in result.rows:
for row in result:
print(row)
.. note::
Expand All @@ -100,7 +100,7 @@ result set is too large,
'WHERE p.employee_id == e.employee_id')
result = snapshot.execute_sql(QUERY)
for row in list(result):
for row in result:
print(row)
.. note::
Expand Down

0 comments on commit eee2181

Please sign in to comment.