(Optional) Common options for this request. If a dict is provided, it must be of the same form as the protobuf message RequestOptions.
retry
google.api_core.retry.Retry
(Optional) The retry settings for this request.
timeout
float
(Optional) The timeout for this request.
column_info
dict
(Optional) dict of mapping between column names and additional column information. An object where column names as keys and custom objects as corresponding values for deserialization. It's specifically useful for data types like protobuf where deserialization logic is on user-specific code. When provided, the custom object enables deserialization of backend-received column data. If not provided, data remains serialized as bytes for Proto Messages and integer for Proto Enums.
(Optional) name of index to use, rather than the table's primary key
limit
int
(Optional) maximum number of rows to return
column_info
dict
(Optional) dict of mapping between column names and additional column information. An object where column names as keys and custom objects as corresponding values for deserialization. It's specifically useful for data types like protobuf where deserialization logic is on user-specific code. When provided, the custom object enables deserialization of backend-received column data. If not provided, data remains serialized as bytes for Proto Messages and integer for Proto Enums.
a result set instance which can be used to consume rows.
run_in_transaction
run_in_transaction(func,*args,**kw)
Perform a unit of work in a transaction, retrying on abort.
Parameters
Name
Description
func
callable
takes a required positional argument, the transaction, and additional positional / keyword arguments as supplied by the caller.
args
tuple
additional positional arguments to be passed to func.
kw
dict
(Optional) keyword arguments to be passed to func. If passed: "timeout_secs" will be removed and used to override the default retry timeout which defines maximum timestamp to continue retrying the transaction. "commit_request_options" will be removed and used to set the request options for the commit request. "max_commit_delay" will be removed and used to set the max commit delay for the request. "transaction_tag" will be removed and used to set the transaction tag for the request. "exclude_txn_from_change_streams" if true, instructs the transaction to be excluded from being recorded in change streams with the DDL option allow_txn_exclusion=true. This does not exclude the transaction from being recorded in the change streams with the DDL option allow_txn_exclusion being false or unset. "isolation_level" sets the isolation level for the transaction.
Exceptions
Type
Description
Exception
reraises any non-ABORT exceptions raised by func.
Returns
Type
Description
Any
The return value of func.
snapshot
snapshot(**kw)
Create a snapshot to perform a set of reads with shared staleness.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class Session (3.57.0)\n\nVersion latestkeyboard_arrow_down\n\n- [3.57.0 (latest)](/python/docs/reference/spanner/latest/google.cloud.spanner_v1.session.Session)\n- [3.56.0](/python/docs/reference/spanner/3.56.0/google.cloud.spanner_v1.session.Session)\n- [3.55.0](/python/docs/reference/spanner/3.55.0/google.cloud.spanner_v1.session.Session)\n- [3.54.0](/python/docs/reference/spanner/3.54.0/google.cloud.spanner_v1.session.Session)\n- [3.53.0](/python/docs/reference/spanner/3.53.0/google.cloud.spanner_v1.session.Session)\n- [3.52.0](/python/docs/reference/spanner/3.52.0/google.cloud.spanner_v1.session.Session)\n- [3.51.0](/python/docs/reference/spanner/3.51.0/google.cloud.spanner_v1.session.Session)\n- [3.50.1](/python/docs/reference/spanner/3.50.1/google.cloud.spanner_v1.session.Session)\n- [3.46.0](/python/docs/reference/spanner/3.46.0/google.cloud.spanner_v1.session.Session)\n- [3.45.0](/python/docs/reference/spanner/3.45.0/google.cloud.spanner_v1.session.Session)\n- [3.44.0](/python/docs/reference/spanner/3.44.0/google.cloud.spanner_v1.session.Session)\n- [3.43.0](/python/docs/reference/spanner/3.43.0/google.cloud.spanner_v1.session.Session)\n- [3.42.0](/python/docs/reference/spanner/3.42.0/google.cloud.spanner_v1.session.Session)\n- [3.41.0](/python/docs/reference/spanner/3.41.0/google.cloud.spanner_v1.session.Session)\n- [3.40.1](/python/docs/reference/spanner/3.40.1/google.cloud.spanner_v1.session.Session)\n- [3.39.0](/python/docs/reference/spanner/3.39.0/google.cloud.spanner_v1.session.Session)\n- [3.38.0](/python/docs/reference/spanner/3.38.0/google.cloud.spanner_v1.session.Session)\n- [3.37.0](/python/docs/reference/spanner/3.37.0/google.cloud.spanner_v1.session.Session)\n- [3.36.0](/python/docs/reference/spanner/3.36.0/google.cloud.spanner_v1.session.Session)\n- [3.35.1](/python/docs/reference/spanner/3.35.1/google.cloud.spanner_v1.session.Session)\n- [3.34.0](/python/docs/reference/spanner/3.34.0/google.cloud.spanner_v1.session.Session)\n- [3.33.0](/python/docs/reference/spanner/3.33.0/google.cloud.spanner_v1.session.Session)\n- [3.32.0](/python/docs/reference/spanner/3.32.0/google.cloud.spanner_v1.session.Session)\n- [3.31.0](/python/docs/reference/spanner/3.31.0/google.cloud.spanner_v1.session.Session)\n- [3.30.0](/python/docs/reference/spanner/3.30.0/google.cloud.spanner_v1.session.Session)\n- [3.29.0](/python/docs/reference/spanner/3.29.0/google.cloud.spanner_v1.session.Session)\n- [3.28.0](/python/docs/reference/spanner/3.28.0/google.cloud.spanner_v1.session.Session)\n- [3.27.1](/python/docs/reference/spanner/3.27.1/google.cloud.spanner_v1.session.Session)\n- [3.26.0](/python/docs/reference/spanner/3.26.0/google.cloud.spanner_v1.session.Session)\n- [3.25.0](/python/docs/reference/spanner/3.25.0/google.cloud.spanner_v1.session.Session)\n- [3.24.0](/python/docs/reference/spanner/3.24.0/google.cloud.spanner_v1.session.Session)\n- [3.23.0](/python/docs/reference/spanner/3.23.0/google.cloud.spanner_v1.session.Session)\n- [3.22.2](/python/docs/reference/spanner/3.22.2/google.cloud.spanner_v1.session.Session)\n- [3.21.0](/python/docs/reference/spanner/3.21.0/google.cloud.spanner_v1.session.Session)\n- [3.20.0](/python/docs/reference/spanner/3.20.0/google.cloud.spanner_v1.session.Session)\n- [3.19.0](/python/docs/reference/spanner/3.19.0/google.cloud.spanner_v1.session.Session)\n- [3.18.0](/python/docs/reference/spanner/3.18.0/google.cloud.spanner_v1.session.Session)\n- [3.17.0](/python/docs/reference/spanner/3.17.0/google.cloud.spanner_v1.session.Session)\n- [3.16.0](/python/docs/reference/spanner/3.16.0/google.cloud.spanner_v1.session.Session)\n- [3.15.1](/python/docs/reference/spanner/3.15.1/google.cloud.spanner_v1.session.Session)\n- [3.14.1](/python/docs/reference/spanner/3.14.1/google.cloud.spanner_v1.session.Session)\n- [3.13.0](/python/docs/reference/spanner/3.13.0/google.cloud.spanner_v1.session.Session)\n- [3.12.1](/python/docs/reference/spanner/3.12.1/google.cloud.spanner_v1.session.Session)\n- [3.11.1](/python/docs/reference/spanner/3.11.1/google.cloud.spanner_v1.session.Session)\n- [3.10.0](/python/docs/reference/spanner/3.10.0/google.cloud.spanner_v1.session.Session)\n- [3.9.0](/python/docs/reference/spanner/3.9.0/google.cloud.spanner_v1.session.Session)\n- [3.8.0](/python/docs/reference/spanner/3.8.0/google.cloud.spanner_v1.session.Session)\n- [3.7.0](/python/docs/reference/spanner/3.7.0/google.cloud.spanner_v1.session.Session)\n- [3.6.0](/python/docs/reference/spanner/3.6.0/google.cloud.spanner_v1.session.Session)\n- [3.5.0](/python/docs/reference/spanner/3.5.0/google.cloud.spanner_v1.session.Session)\n- [3.4.0](/python/docs/reference/spanner/3.4.0/google.cloud.spanner_v1.session.Session)\n- [3.3.0](/python/docs/reference/spanner/3.3.0/google.cloud.spanner_v1.session.Session)\n- [3.2.0](/python/docs/reference/spanner/3.2.0/google.cloud.spanner_v1.session.Session)\n- [3.1.0](/python/docs/reference/spanner/3.1.0/google.cloud.spanner_v1.session.Session)\n- [3.0.0](/python/docs/reference/spanner/3.0.0/google.cloud.spanner_v1.session.Session)\n- [2.1.1](/python/docs/reference/spanner/2.1.1/google.cloud.spanner_v1.session.Session)\n- [2.0.0](/python/docs/reference/spanner/2.0.0/google.cloud.spanner_v1.session.Session)\n- [1.19.3](/python/docs/reference/spanner/1.19.3/google.cloud.spanner_v1.session.Session)\n- [1.18.0](/python/docs/reference/spanner/1.18.0/google.cloud.spanner_v1.session.Session)\n- [1.17.1](/python/docs/reference/spanner/1.17.1/google.cloud.spanner_v1.session.Session)\n- [1.16.0](/python/docs/reference/spanner/1.16.0/google.cloud.spanner_v1.session.Session)\n- [1.15.1](/python/docs/reference/spanner/1.15.1/google.cloud.spanner_v1.session.Session)\n- [1.14.0](/python/docs/reference/spanner/1.14.0/google.cloud.spanner_v1.session.Session)\n- [1.13.0](/python/docs/reference/spanner/1.13.0/google.cloud.spanner_v1.session.Session)\n- [1.12.0](/python/docs/reference/spanner/1.12.0/google.cloud.spanner_v1.session.Session)\n- [1.11.0](/python/docs/reference/spanner/1.11.0/google.cloud.spanner_v1.session.Session)\n- [1.10.0](/python/docs/reference/spanner/1.10.0/google.cloud.spanner_v1.session.Session) \n\n Session(database, labels=None, database_role=None, is_multiplexed=False)\n\nRepresentation of a Cloud Spanner Session.\n\nWe can use a `Session` to:\n\n- `create` the session\n- Use `exists` to check for the existence of the session\n- `drop` the session\n\nProperties\n----------\n\n### database_role\n\nUser-assigned database-role for the session.\n\n### is_multiplexed\n\nWhether this session is a multiplexed session.\n\n### labels\n\nUser-assigned labels for the session.\n\n### last_use_time\n\nApproximate last use time of this session\n\n### name\n\nSession name used in requests.\n\n\u003cbr /\u003e\n\n| **Note:** This property will not change if `session_id` does not, but the return value is not cached.\n`\"projects/../instances/../databases/../sessions/{session_id}\"`\n\n\u003cbr /\u003e\n\n### session_id\n\nRead-only ID, set by the back-end during `create`.\n\nMethods\n-------\n\n### batch\n\n batch()\n\nFactory to create a batch for this session.\n\n### create\n\n create()\n\nCreate this session, bound to its database.\n\nSee\n\u003chttps://cloud.google.com/spanner/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.CreateSession\u003e\n\n### delete\n\n delete()\n\nDelete this session.\n\nSee\n\u003chttps://cloud.google.com/spanner/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.GetSession\u003e\n\n### execute_sql\n\n execute_sql(\n sql,\n params=None,\n param_types=None,\n query_mode=None,\n query_options=None,\n request_options=None,\n retry=_MethodDefault._DEFAULT_VALUE,\n timeout=_MethodDefault._DEFAULT_VALUE,\n column_info=None,\n )\n\nPerform an `ExecuteStreamingSql` API request.\n\n### exists\n\n exists()\n\nTest for the existence of this session.\n\nSee\n\u003chttps://cloud.google.com/spanner/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.GetSession\u003e\n\n### ping\n\n ping()\n\nPing the session to keep it alive by executing \"SELECT 1\".\n\n### read\n\n read(table, columns, keyset, index=\"\", limit=0, column_info=None)\n\nPerform a `StreamingRead` API request for rows in a table.\n\n### run_in_transaction\n\n run_in_transaction(func, *args, **kw)\n\nPerform a unit of work in a transaction, retrying on abort.\n\n### snapshot\n\n snapshot(**kw)\n\nCreate a snapshot to perform a set of reads with shared staleness.\n\nSee\n\u003chttps://cloud.google.com/spanner/reference/rpc/google.spanner.v1#google.spanner.v1.TransactionOptions.ReadOnly\u003e\n\n### transaction\n\n transaction() -\u003e google.cloud.spanner_v1.transaction.Transaction\n\nCreate a transaction to perform a set of reads with shared staleness."]]