Snapshot API#

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

class google.cloud.spanner.snapshot.Snapshot(session, read_timestamp=None, min_read_timestamp=None, max_staleness=None, exact_staleness=None)[source]#

Bases: google.cloud.spanner.snapshot._SnapshotBase

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:
  • 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.