Module snapshot (3.19.0)

Stay organized with collections Save and categorize content based on your preferences.

Model a set of read-only queries to a database as a snapshot.

Classes

Snapshot

Snapshot(
    session,
    read_timestamp=None,
    min_read_timestamp=None,
    max_staleness=None,
    exact_staleness=None,
    multi_use=False,
)

Allow a set of reads / SQL statements with shared staleness.

See https://cloud.google.com/spanner/reference/rpc/google.spanner.v1#google.spanner.v1.TransactionOptions.ReadOnly

If no options are passed, reads will use the strong model, reading at a timestamp where all previously committed transactions are visible.

Parameters
NameDescription
session Session

The session used to perform the commit.

read_timestamp `datetime.datetime`

Execute all reads at the given timestamp.

min_read_timestamp `datetime.datetime`

Execute all reads at a timestamp >= min_read_timestamp.

max_staleness `datetime.timedelta`

Read data at a timestamp >= NOW - max_staleness seconds.

exact_staleness `datetime.timedelta`

Execute all reads at a timestamp that is exact_staleness old.

multi_use `bool`

If true, multiple read / execute_sql calls can be performed with the snapshot in the context of a read-only transaction, used to ensure isolation / consistency. Incompatible with max_staleness and min_read_timestamp.