Skip to content

Commit 19855d1

Browse files
authored
Spanner: Update sessions to database in snapshot_usage (googleapis#4509)
1 parent 28a1d28 commit 19855d1

1 file changed

Lines changed: 9 additions & 17 deletions

File tree

docs/spanner/snapshot-usage.rst

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ transactions are visible:
1515

1616
.. code:: python
1717
18-
snapshot = session.snapshot()
18+
snapshot = database.snapshot()
1919
2020
You can also specify a weaker bound, which can either be to perform all
2121
reads as of a given timestamp:
@@ -25,21 +25,21 @@ reads as of a given timestamp:
2525
import datetime
2626
from pytz import UTC
2727
TIMESTAMP = datetime.utcnow().replace(tzinfo=UTC)
28-
snapshot = session.snapshot(read_timestamp=TIMESTAMP)
28+
snapshot = database.snapshot(read_timestamp=TIMESTAMP)
2929
3030
or as of a given duration in the past:
3131

3232
.. code:: python
3333
3434
import datetime
3535
DURATION = datetime.timedelta(seconds=5)
36-
snapshot = session.snapshot(exact_staleness=DURATION)
36+
snapshot = database.snapshot(exact_staleness=DURATION)
3737
3838
3939
Read Table Data
4040
---------------
4141

42-
Read data for selected rows from a table in the session's database. Calls
42+
Read data for selected rows from a table in the database. Calls
4343
the ``Read`` API, which returns all rows specified in ``key_set``, or else
4444
fails if the result set is too large,
4545

@@ -55,12 +55,8 @@ fails if the result set is too large,
5555
5656
.. note::
5757

58-
The result set returned by
59-
:meth:`~google.cloud.spanner.snapshot.Snapshot.execute_sql` *must not* be
60-
iterated after the snapshot's session has been returned to the database's
61-
session pool. Therefore, unless your application creates sessions
62-
manually, perform all iteration within the context of the
63-
``with database.snapshot()`` block.
58+
Perform all iteration within the context of the ``with database.snapshot()``
59+
block.
6460

6561
.. note::
6662

@@ -87,7 +83,7 @@ fails if the result set is too large,
8783
Execute a SQL Select Statement
8884
------------------------------
8985

90-
Read data from a query against tables in the session's database. Calls
86+
Read data from a query against tables in the database. Calls
9187
the ``ExecuteSql`` API, which returns all rows matching the query, or else
9288
fails if the result set is too large,
9389

@@ -105,12 +101,8 @@ fails if the result set is too large,
105101
106102
.. note::
107103

108-
The result set returned by
109-
:meth:`~google.cloud.spanner.snapshot.Snapshot.execute_sql` *must not* be
110-
iterated after the snapshot's session has been returned to the database's
111-
session pool. Therefore, unless your application creates sessions
112-
manually, perform all iteration within the context of the
113-
``with database.snapshot()`` block.
104+
Perform all iteration within the context of the ``with database.snapshot()``
105+
block.
114106

115107
.. note::
116108

0 commit comments

Comments
 (0)