google-cloud-spanner 3.55.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/cloud/spanner.py +47 -0
- google/cloud/spanner_admin_database_v1/__init__.py +146 -0
- google/cloud/spanner_admin_database_v1/gapic_metadata.json +418 -0
- google/cloud/spanner_admin_database_v1/gapic_version.py +16 -0
- google/cloud/spanner_admin_database_v1/py.typed +2 -0
- google/cloud/spanner_admin_database_v1/services/__init__.py +15 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/__init__.py +22 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py +4097 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/client.py +4602 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/pagers.py +989 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/__init__.py +38 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py +820 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py +1303 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py +1688 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/rest.py +6512 -0
- google/cloud/spanner_admin_database_v1/services/database_admin/transports/rest_base.py +1650 -0
- google/cloud/spanner_admin_database_v1/types/__init__.py +144 -0
- google/cloud/spanner_admin_database_v1/types/backup.py +1106 -0
- google/cloud/spanner_admin_database_v1/types/backup_schedule.py +369 -0
- google/cloud/spanner_admin_database_v1/types/common.py +180 -0
- google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py +1303 -0
- google/cloud/spanner_admin_instance_v1/__init__.py +110 -0
- google/cloud/spanner_admin_instance_v1/gapic_metadata.json +343 -0
- google/cloud/spanner_admin_instance_v1/gapic_version.py +16 -0
- google/cloud/spanner_admin_instance_v1/py.typed +2 -0
- google/cloud/spanner_admin_instance_v1/services/__init__.py +15 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/__init__.py +22 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py +3466 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py +3881 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/pagers.py +856 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/__init__.py +38 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py +545 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py +1347 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py +1539 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/rest.py +4834 -0
- google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/rest_base.py +1198 -0
- google/cloud/spanner_admin_instance_v1/types/__init__.py +104 -0
- google/cloud/spanner_admin_instance_v1/types/common.py +99 -0
- google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py +2375 -0
- google/cloud/spanner_dbapi/__init__.py +93 -0
- google/cloud/spanner_dbapi/_helpers.py +113 -0
- google/cloud/spanner_dbapi/batch_dml_executor.py +135 -0
- google/cloud/spanner_dbapi/checksum.py +80 -0
- google/cloud/spanner_dbapi/client_side_statement_executor.py +140 -0
- google/cloud/spanner_dbapi/client_side_statement_parser.py +106 -0
- google/cloud/spanner_dbapi/connection.py +818 -0
- google/cloud/spanner_dbapi/cursor.py +609 -0
- google/cloud/spanner_dbapi/exceptions.py +172 -0
- google/cloud/spanner_dbapi/parse_utils.py +392 -0
- google/cloud/spanner_dbapi/parsed_statement.py +63 -0
- google/cloud/spanner_dbapi/parser.py +258 -0
- google/cloud/spanner_dbapi/partition_helper.py +41 -0
- google/cloud/spanner_dbapi/transaction_helper.py +294 -0
- google/cloud/spanner_dbapi/types.py +106 -0
- google/cloud/spanner_dbapi/utils.py +147 -0
- google/cloud/spanner_dbapi/version.py +20 -0
- google/cloud/spanner_v1/__init__.py +154 -0
- google/cloud/spanner_v1/_helpers.py +751 -0
- google/cloud/spanner_v1/_opentelemetry_tracing.py +165 -0
- google/cloud/spanner_v1/backup.py +397 -0
- google/cloud/spanner_v1/batch.py +433 -0
- google/cloud/spanner_v1/client.py +538 -0
- google/cloud/spanner_v1/data_types.py +350 -0
- google/cloud/spanner_v1/database.py +1968 -0
- google/cloud/spanner_v1/database_sessions_manager.py +249 -0
- google/cloud/spanner_v1/gapic_metadata.json +268 -0
- google/cloud/spanner_v1/gapic_version.py +16 -0
- google/cloud/spanner_v1/instance.py +735 -0
- google/cloud/spanner_v1/keyset.py +193 -0
- google/cloud/spanner_v1/merged_result_set.py +146 -0
- google/cloud/spanner_v1/metrics/constants.py +71 -0
- google/cloud/spanner_v1/metrics/metrics_capture.py +75 -0
- google/cloud/spanner_v1/metrics/metrics_exporter.py +384 -0
- google/cloud/spanner_v1/metrics/metrics_interceptor.py +156 -0
- google/cloud/spanner_v1/metrics/metrics_tracer.py +588 -0
- google/cloud/spanner_v1/metrics/metrics_tracer_factory.py +328 -0
- google/cloud/spanner_v1/metrics/spanner_metrics_tracer_factory.py +172 -0
- google/cloud/spanner_v1/param_types.py +110 -0
- google/cloud/spanner_v1/pool.py +813 -0
- google/cloud/spanner_v1/py.typed +2 -0
- google/cloud/spanner_v1/request_id_header.py +64 -0
- google/cloud/spanner_v1/services/__init__.py +15 -0
- google/cloud/spanner_v1/services/spanner/__init__.py +22 -0
- google/cloud/spanner_v1/services/spanner/async_client.py +2205 -0
- google/cloud/spanner_v1/services/spanner/client.py +2624 -0
- google/cloud/spanner_v1/services/spanner/pagers.py +196 -0
- google/cloud/spanner_v1/services/spanner/transports/__init__.py +38 -0
- google/cloud/spanner_v1/services/spanner/transports/base.py +520 -0
- google/cloud/spanner_v1/services/spanner/transports/grpc.py +911 -0
- google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py +1144 -0
- google/cloud/spanner_v1/services/spanner/transports/rest.py +3468 -0
- google/cloud/spanner_v1/services/spanner/transports/rest_base.py +981 -0
- google/cloud/spanner_v1/session.py +631 -0
- google/cloud/spanner_v1/session_options.py +133 -0
- google/cloud/spanner_v1/snapshot.py +1057 -0
- google/cloud/spanner_v1/streamed.py +402 -0
- google/cloud/spanner_v1/table.py +181 -0
- google/cloud/spanner_v1/testing/__init__.py +0 -0
- google/cloud/spanner_v1/testing/database_test.py +121 -0
- google/cloud/spanner_v1/testing/interceptors.py +118 -0
- google/cloud/spanner_v1/testing/mock_database_admin.py +38 -0
- google/cloud/spanner_v1/testing/mock_spanner.py +261 -0
- google/cloud/spanner_v1/testing/spanner_database_admin_pb2_grpc.py +1267 -0
- google/cloud/spanner_v1/testing/spanner_pb2_grpc.py +882 -0
- google/cloud/spanner_v1/transaction.py +747 -0
- google/cloud/spanner_v1/types/__init__.py +118 -0
- google/cloud/spanner_v1/types/commit_response.py +94 -0
- google/cloud/spanner_v1/types/keys.py +248 -0
- google/cloud/spanner_v1/types/mutation.py +201 -0
- google/cloud/spanner_v1/types/query_plan.py +220 -0
- google/cloud/spanner_v1/types/result_set.py +379 -0
- google/cloud/spanner_v1/types/spanner.py +1815 -0
- google/cloud/spanner_v1/types/transaction.py +818 -0
- google/cloud/spanner_v1/types/type.py +288 -0
- google_cloud_spanner-3.55.0.dist-info/LICENSE +202 -0
- google_cloud_spanner-3.55.0.dist-info/METADATA +318 -0
- google_cloud_spanner-3.55.0.dist-info/RECORD +119 -0
- google_cloud_spanner-3.55.0.dist-info/WHEEL +5 -0
- google_cloud_spanner-3.55.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2025 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
from .commit_response import (
|
|
17
|
+
CommitResponse,
|
|
18
|
+
)
|
|
19
|
+
from .keys import (
|
|
20
|
+
KeyRange,
|
|
21
|
+
KeySet,
|
|
22
|
+
)
|
|
23
|
+
from .mutation import (
|
|
24
|
+
Mutation,
|
|
25
|
+
)
|
|
26
|
+
from .query_plan import (
|
|
27
|
+
PlanNode,
|
|
28
|
+
QueryPlan,
|
|
29
|
+
)
|
|
30
|
+
from .result_set import (
|
|
31
|
+
PartialResultSet,
|
|
32
|
+
ResultSet,
|
|
33
|
+
ResultSetMetadata,
|
|
34
|
+
ResultSetStats,
|
|
35
|
+
)
|
|
36
|
+
from .spanner import (
|
|
37
|
+
BatchCreateSessionsRequest,
|
|
38
|
+
BatchCreateSessionsResponse,
|
|
39
|
+
BatchWriteRequest,
|
|
40
|
+
BatchWriteResponse,
|
|
41
|
+
BeginTransactionRequest,
|
|
42
|
+
CommitRequest,
|
|
43
|
+
CreateSessionRequest,
|
|
44
|
+
DeleteSessionRequest,
|
|
45
|
+
DirectedReadOptions,
|
|
46
|
+
ExecuteBatchDmlRequest,
|
|
47
|
+
ExecuteBatchDmlResponse,
|
|
48
|
+
ExecuteSqlRequest,
|
|
49
|
+
GetSessionRequest,
|
|
50
|
+
ListSessionsRequest,
|
|
51
|
+
ListSessionsResponse,
|
|
52
|
+
Partition,
|
|
53
|
+
PartitionOptions,
|
|
54
|
+
PartitionQueryRequest,
|
|
55
|
+
PartitionReadRequest,
|
|
56
|
+
PartitionResponse,
|
|
57
|
+
ReadRequest,
|
|
58
|
+
RequestOptions,
|
|
59
|
+
RollbackRequest,
|
|
60
|
+
Session,
|
|
61
|
+
)
|
|
62
|
+
from .transaction import (
|
|
63
|
+
MultiplexedSessionPrecommitToken,
|
|
64
|
+
Transaction,
|
|
65
|
+
TransactionOptions,
|
|
66
|
+
TransactionSelector,
|
|
67
|
+
)
|
|
68
|
+
from .type import (
|
|
69
|
+
StructType,
|
|
70
|
+
Type,
|
|
71
|
+
TypeAnnotationCode,
|
|
72
|
+
TypeCode,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
__all__ = (
|
|
76
|
+
"CommitResponse",
|
|
77
|
+
"KeyRange",
|
|
78
|
+
"KeySet",
|
|
79
|
+
"Mutation",
|
|
80
|
+
"PlanNode",
|
|
81
|
+
"QueryPlan",
|
|
82
|
+
"PartialResultSet",
|
|
83
|
+
"ResultSet",
|
|
84
|
+
"ResultSetMetadata",
|
|
85
|
+
"ResultSetStats",
|
|
86
|
+
"BatchCreateSessionsRequest",
|
|
87
|
+
"BatchCreateSessionsResponse",
|
|
88
|
+
"BatchWriteRequest",
|
|
89
|
+
"BatchWriteResponse",
|
|
90
|
+
"BeginTransactionRequest",
|
|
91
|
+
"CommitRequest",
|
|
92
|
+
"CreateSessionRequest",
|
|
93
|
+
"DeleteSessionRequest",
|
|
94
|
+
"DirectedReadOptions",
|
|
95
|
+
"ExecuteBatchDmlRequest",
|
|
96
|
+
"ExecuteBatchDmlResponse",
|
|
97
|
+
"ExecuteSqlRequest",
|
|
98
|
+
"GetSessionRequest",
|
|
99
|
+
"ListSessionsRequest",
|
|
100
|
+
"ListSessionsResponse",
|
|
101
|
+
"Partition",
|
|
102
|
+
"PartitionOptions",
|
|
103
|
+
"PartitionQueryRequest",
|
|
104
|
+
"PartitionReadRequest",
|
|
105
|
+
"PartitionResponse",
|
|
106
|
+
"ReadRequest",
|
|
107
|
+
"RequestOptions",
|
|
108
|
+
"RollbackRequest",
|
|
109
|
+
"Session",
|
|
110
|
+
"MultiplexedSessionPrecommitToken",
|
|
111
|
+
"Transaction",
|
|
112
|
+
"TransactionOptions",
|
|
113
|
+
"TransactionSelector",
|
|
114
|
+
"StructType",
|
|
115
|
+
"Type",
|
|
116
|
+
"TypeAnnotationCode",
|
|
117
|
+
"TypeCode",
|
|
118
|
+
)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2025 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from typing import MutableMapping, MutableSequence
|
|
19
|
+
|
|
20
|
+
import proto # type: ignore
|
|
21
|
+
|
|
22
|
+
from google.cloud.spanner_v1.types import transaction
|
|
23
|
+
from google.protobuf import timestamp_pb2 # type: ignore
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
__protobuf__ = proto.module(
|
|
27
|
+
package="google.spanner.v1",
|
|
28
|
+
manifest={
|
|
29
|
+
"CommitResponse",
|
|
30
|
+
},
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class CommitResponse(proto.Message):
|
|
35
|
+
r"""The response for [Commit][google.spanner.v1.Spanner.Commit].
|
|
36
|
+
|
|
37
|
+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
|
|
38
|
+
|
|
39
|
+
Attributes:
|
|
40
|
+
commit_timestamp (google.protobuf.timestamp_pb2.Timestamp):
|
|
41
|
+
The Cloud Spanner timestamp at which the
|
|
42
|
+
transaction committed.
|
|
43
|
+
commit_stats (google.cloud.spanner_v1.types.CommitResponse.CommitStats):
|
|
44
|
+
The statistics about this Commit. Not returned by default.
|
|
45
|
+
For more information, see
|
|
46
|
+
[CommitRequest.return_commit_stats][google.spanner.v1.CommitRequest.return_commit_stats].
|
|
47
|
+
precommit_token (google.cloud.spanner_v1.types.MultiplexedSessionPrecommitToken):
|
|
48
|
+
If specified, transaction has not committed
|
|
49
|
+
yet. Clients must retry the commit with the new
|
|
50
|
+
precommit token.
|
|
51
|
+
|
|
52
|
+
This field is a member of `oneof`_ ``MultiplexedSessionRetry``.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
class CommitStats(proto.Message):
|
|
56
|
+
r"""Additional statistics about a commit.
|
|
57
|
+
|
|
58
|
+
Attributes:
|
|
59
|
+
mutation_count (int):
|
|
60
|
+
The total number of mutations for the transaction. Knowing
|
|
61
|
+
the ``mutation_count`` value can help you maximize the
|
|
62
|
+
number of mutations in a transaction and minimize the number
|
|
63
|
+
of API round trips. You can also monitor this value to
|
|
64
|
+
prevent transactions from exceeding the system
|
|
65
|
+
`limit <https://cloud.google.com/spanner/quotas#limits_for_creating_reading_updating_and_deleting_data>`__.
|
|
66
|
+
If the number of mutations exceeds the limit, the server
|
|
67
|
+
returns
|
|
68
|
+
`INVALID_ARGUMENT <https://cloud.google.com/spanner/docs/reference/rest/v1/Code#ENUM_VALUES.INVALID_ARGUMENT>`__.
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
mutation_count: int = proto.Field(
|
|
72
|
+
proto.INT64,
|
|
73
|
+
number=1,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
commit_timestamp: timestamp_pb2.Timestamp = proto.Field(
|
|
77
|
+
proto.MESSAGE,
|
|
78
|
+
number=1,
|
|
79
|
+
message=timestamp_pb2.Timestamp,
|
|
80
|
+
)
|
|
81
|
+
commit_stats: CommitStats = proto.Field(
|
|
82
|
+
proto.MESSAGE,
|
|
83
|
+
number=2,
|
|
84
|
+
message=CommitStats,
|
|
85
|
+
)
|
|
86
|
+
precommit_token: transaction.MultiplexedSessionPrecommitToken = proto.Field(
|
|
87
|
+
proto.MESSAGE,
|
|
88
|
+
number=4,
|
|
89
|
+
oneof="MultiplexedSessionRetry",
|
|
90
|
+
message=transaction.MultiplexedSessionPrecommitToken,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
__all__ = tuple(sorted(__protobuf__.manifest))
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2025 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from typing import MutableMapping, MutableSequence
|
|
19
|
+
|
|
20
|
+
import proto # type: ignore
|
|
21
|
+
|
|
22
|
+
from google.protobuf import struct_pb2 # type: ignore
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
__protobuf__ = proto.module(
|
|
26
|
+
package="google.spanner.v1",
|
|
27
|
+
manifest={
|
|
28
|
+
"KeyRange",
|
|
29
|
+
"KeySet",
|
|
30
|
+
},
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class KeyRange(proto.Message):
|
|
35
|
+
r"""KeyRange represents a range of rows in a table or index.
|
|
36
|
+
|
|
37
|
+
A range has a start key and an end key. These keys can be open or
|
|
38
|
+
closed, indicating if the range includes rows with that key.
|
|
39
|
+
|
|
40
|
+
Keys are represented by lists, where the ith value in the list
|
|
41
|
+
corresponds to the ith component of the table or index primary key.
|
|
42
|
+
Individual values are encoded as described
|
|
43
|
+
[here][google.spanner.v1.TypeCode].
|
|
44
|
+
|
|
45
|
+
For example, consider the following table definition:
|
|
46
|
+
|
|
47
|
+
::
|
|
48
|
+
|
|
49
|
+
CREATE TABLE UserEvents (
|
|
50
|
+
UserName STRING(MAX),
|
|
51
|
+
EventDate STRING(10)
|
|
52
|
+
) PRIMARY KEY(UserName, EventDate);
|
|
53
|
+
|
|
54
|
+
The following keys name rows in this table:
|
|
55
|
+
|
|
56
|
+
::
|
|
57
|
+
|
|
58
|
+
["Bob", "2014-09-23"]
|
|
59
|
+
["Alfred", "2015-06-12"]
|
|
60
|
+
|
|
61
|
+
Since the ``UserEvents`` table's ``PRIMARY KEY`` clause names two
|
|
62
|
+
columns, each ``UserEvents`` key has two elements; the first is the
|
|
63
|
+
``UserName``, and the second is the ``EventDate``.
|
|
64
|
+
|
|
65
|
+
Key ranges with multiple components are interpreted
|
|
66
|
+
lexicographically by component using the table or index key's
|
|
67
|
+
declared sort order. For example, the following range returns all
|
|
68
|
+
events for user ``"Bob"`` that occurred in the year 2015:
|
|
69
|
+
|
|
70
|
+
::
|
|
71
|
+
|
|
72
|
+
"start_closed": ["Bob", "2015-01-01"]
|
|
73
|
+
"end_closed": ["Bob", "2015-12-31"]
|
|
74
|
+
|
|
75
|
+
Start and end keys can omit trailing key components. This affects
|
|
76
|
+
the inclusion and exclusion of rows that exactly match the provided
|
|
77
|
+
key components: if the key is closed, then rows that exactly match
|
|
78
|
+
the provided components are included; if the key is open, then rows
|
|
79
|
+
that exactly match are not included.
|
|
80
|
+
|
|
81
|
+
For example, the following range includes all events for ``"Bob"``
|
|
82
|
+
that occurred during and after the year 2000:
|
|
83
|
+
|
|
84
|
+
::
|
|
85
|
+
|
|
86
|
+
"start_closed": ["Bob", "2000-01-01"]
|
|
87
|
+
"end_closed": ["Bob"]
|
|
88
|
+
|
|
89
|
+
The next example retrieves all events for ``"Bob"``:
|
|
90
|
+
|
|
91
|
+
::
|
|
92
|
+
|
|
93
|
+
"start_closed": ["Bob"]
|
|
94
|
+
"end_closed": ["Bob"]
|
|
95
|
+
|
|
96
|
+
To retrieve events before the year 2000:
|
|
97
|
+
|
|
98
|
+
::
|
|
99
|
+
|
|
100
|
+
"start_closed": ["Bob"]
|
|
101
|
+
"end_open": ["Bob", "2000-01-01"]
|
|
102
|
+
|
|
103
|
+
The following range includes all rows in the table:
|
|
104
|
+
|
|
105
|
+
::
|
|
106
|
+
|
|
107
|
+
"start_closed": []
|
|
108
|
+
"end_closed": []
|
|
109
|
+
|
|
110
|
+
This range returns all users whose ``UserName`` begins with any
|
|
111
|
+
character from A to C:
|
|
112
|
+
|
|
113
|
+
::
|
|
114
|
+
|
|
115
|
+
"start_closed": ["A"]
|
|
116
|
+
"end_open": ["D"]
|
|
117
|
+
|
|
118
|
+
This range returns all users whose ``UserName`` begins with B:
|
|
119
|
+
|
|
120
|
+
::
|
|
121
|
+
|
|
122
|
+
"start_closed": ["B"]
|
|
123
|
+
"end_open": ["C"]
|
|
124
|
+
|
|
125
|
+
Key ranges honor column sort order. For example, suppose a table is
|
|
126
|
+
defined as follows:
|
|
127
|
+
|
|
128
|
+
::
|
|
129
|
+
|
|
130
|
+
CREATE TABLE DescendingSortedTable {
|
|
131
|
+
Key INT64,
|
|
132
|
+
...
|
|
133
|
+
) PRIMARY KEY(Key DESC);
|
|
134
|
+
|
|
135
|
+
The following range retrieves all rows with key values between 1 and
|
|
136
|
+
100 inclusive:
|
|
137
|
+
|
|
138
|
+
::
|
|
139
|
+
|
|
140
|
+
"start_closed": ["100"]
|
|
141
|
+
"end_closed": ["1"]
|
|
142
|
+
|
|
143
|
+
Note that 100 is passed as the start, and 1 is passed as the end,
|
|
144
|
+
because ``Key`` is a descending column in the schema.
|
|
145
|
+
|
|
146
|
+
This message has `oneof`_ fields (mutually exclusive fields).
|
|
147
|
+
For each oneof, at most one member field can be set at the same time.
|
|
148
|
+
Setting any member of the oneof automatically clears all other
|
|
149
|
+
members.
|
|
150
|
+
|
|
151
|
+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
|
|
152
|
+
|
|
153
|
+
Attributes:
|
|
154
|
+
start_closed (google.protobuf.struct_pb2.ListValue):
|
|
155
|
+
If the start is closed, then the range includes all rows
|
|
156
|
+
whose first ``len(start_closed)`` key columns exactly match
|
|
157
|
+
``start_closed``.
|
|
158
|
+
|
|
159
|
+
This field is a member of `oneof`_ ``start_key_type``.
|
|
160
|
+
start_open (google.protobuf.struct_pb2.ListValue):
|
|
161
|
+
If the start is open, then the range excludes rows whose
|
|
162
|
+
first ``len(start_open)`` key columns exactly match
|
|
163
|
+
``start_open``.
|
|
164
|
+
|
|
165
|
+
This field is a member of `oneof`_ ``start_key_type``.
|
|
166
|
+
end_closed (google.protobuf.struct_pb2.ListValue):
|
|
167
|
+
If the end is closed, then the range includes all rows whose
|
|
168
|
+
first ``len(end_closed)`` key columns exactly match
|
|
169
|
+
``end_closed``.
|
|
170
|
+
|
|
171
|
+
This field is a member of `oneof`_ ``end_key_type``.
|
|
172
|
+
end_open (google.protobuf.struct_pb2.ListValue):
|
|
173
|
+
If the end is open, then the range excludes rows whose first
|
|
174
|
+
``len(end_open)`` key columns exactly match ``end_open``.
|
|
175
|
+
|
|
176
|
+
This field is a member of `oneof`_ ``end_key_type``.
|
|
177
|
+
"""
|
|
178
|
+
|
|
179
|
+
start_closed: struct_pb2.ListValue = proto.Field(
|
|
180
|
+
proto.MESSAGE,
|
|
181
|
+
number=1,
|
|
182
|
+
oneof="start_key_type",
|
|
183
|
+
message=struct_pb2.ListValue,
|
|
184
|
+
)
|
|
185
|
+
start_open: struct_pb2.ListValue = proto.Field(
|
|
186
|
+
proto.MESSAGE,
|
|
187
|
+
number=2,
|
|
188
|
+
oneof="start_key_type",
|
|
189
|
+
message=struct_pb2.ListValue,
|
|
190
|
+
)
|
|
191
|
+
end_closed: struct_pb2.ListValue = proto.Field(
|
|
192
|
+
proto.MESSAGE,
|
|
193
|
+
number=3,
|
|
194
|
+
oneof="end_key_type",
|
|
195
|
+
message=struct_pb2.ListValue,
|
|
196
|
+
)
|
|
197
|
+
end_open: struct_pb2.ListValue = proto.Field(
|
|
198
|
+
proto.MESSAGE,
|
|
199
|
+
number=4,
|
|
200
|
+
oneof="end_key_type",
|
|
201
|
+
message=struct_pb2.ListValue,
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
class KeySet(proto.Message):
|
|
206
|
+
r"""``KeySet`` defines a collection of Cloud Spanner keys and/or key
|
|
207
|
+
ranges. All the keys are expected to be in the same table or index.
|
|
208
|
+
The keys need not be sorted in any particular way.
|
|
209
|
+
|
|
210
|
+
If the same key is specified multiple times in the set (for example
|
|
211
|
+
if two ranges, two keys, or a key and a range overlap), Cloud
|
|
212
|
+
Spanner behaves as if the key were only specified once.
|
|
213
|
+
|
|
214
|
+
Attributes:
|
|
215
|
+
keys (MutableSequence[google.protobuf.struct_pb2.ListValue]):
|
|
216
|
+
A list of specific keys. Entries in ``keys`` should have
|
|
217
|
+
exactly as many elements as there are columns in the primary
|
|
218
|
+
or index key with which this ``KeySet`` is used. Individual
|
|
219
|
+
key values are encoded as described
|
|
220
|
+
[here][google.spanner.v1.TypeCode].
|
|
221
|
+
ranges (MutableSequence[google.cloud.spanner_v1.types.KeyRange]):
|
|
222
|
+
A list of key ranges. See
|
|
223
|
+
[KeyRange][google.spanner.v1.KeyRange] for more information
|
|
224
|
+
about key range specifications.
|
|
225
|
+
all_ (bool):
|
|
226
|
+
For convenience ``all`` can be set to ``true`` to indicate
|
|
227
|
+
that this ``KeySet`` matches all keys in the table or index.
|
|
228
|
+
Note that any keys specified in ``keys`` or ``ranges`` are
|
|
229
|
+
only yielded once.
|
|
230
|
+
"""
|
|
231
|
+
|
|
232
|
+
keys: MutableSequence[struct_pb2.ListValue] = proto.RepeatedField(
|
|
233
|
+
proto.MESSAGE,
|
|
234
|
+
number=1,
|
|
235
|
+
message=struct_pb2.ListValue,
|
|
236
|
+
)
|
|
237
|
+
ranges: MutableSequence["KeyRange"] = proto.RepeatedField(
|
|
238
|
+
proto.MESSAGE,
|
|
239
|
+
number=2,
|
|
240
|
+
message="KeyRange",
|
|
241
|
+
)
|
|
242
|
+
all_: bool = proto.Field(
|
|
243
|
+
proto.BOOL,
|
|
244
|
+
number=3,
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
__all__ = tuple(sorted(__protobuf__.manifest))
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2025 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from typing import MutableMapping, MutableSequence
|
|
19
|
+
|
|
20
|
+
import proto # type: ignore
|
|
21
|
+
|
|
22
|
+
from google.cloud.spanner_v1.types import keys
|
|
23
|
+
from google.protobuf import struct_pb2 # type: ignore
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
__protobuf__ = proto.module(
|
|
27
|
+
package="google.spanner.v1",
|
|
28
|
+
manifest={
|
|
29
|
+
"Mutation",
|
|
30
|
+
},
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class Mutation(proto.Message):
|
|
35
|
+
r"""A modification to one or more Cloud Spanner rows. Mutations can be
|
|
36
|
+
applied to a Cloud Spanner database by sending them in a
|
|
37
|
+
[Commit][google.spanner.v1.Spanner.Commit] call.
|
|
38
|
+
|
|
39
|
+
This message has `oneof`_ fields (mutually exclusive fields).
|
|
40
|
+
For each oneof, at most one member field can be set at the same time.
|
|
41
|
+
Setting any member of the oneof automatically clears all other
|
|
42
|
+
members.
|
|
43
|
+
|
|
44
|
+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
|
|
45
|
+
|
|
46
|
+
Attributes:
|
|
47
|
+
insert (google.cloud.spanner_v1.types.Mutation.Write):
|
|
48
|
+
Insert new rows in a table. If any of the rows already
|
|
49
|
+
exist, the write or transaction fails with error
|
|
50
|
+
``ALREADY_EXISTS``.
|
|
51
|
+
|
|
52
|
+
This field is a member of `oneof`_ ``operation``.
|
|
53
|
+
update (google.cloud.spanner_v1.types.Mutation.Write):
|
|
54
|
+
Update existing rows in a table. If any of the rows does not
|
|
55
|
+
already exist, the transaction fails with error
|
|
56
|
+
``NOT_FOUND``.
|
|
57
|
+
|
|
58
|
+
This field is a member of `oneof`_ ``operation``.
|
|
59
|
+
insert_or_update (google.cloud.spanner_v1.types.Mutation.Write):
|
|
60
|
+
Like [insert][google.spanner.v1.Mutation.insert], except
|
|
61
|
+
that if the row already exists, then its column values are
|
|
62
|
+
overwritten with the ones provided. Any column values not
|
|
63
|
+
explicitly written are preserved.
|
|
64
|
+
|
|
65
|
+
When using
|
|
66
|
+
[insert_or_update][google.spanner.v1.Mutation.insert_or_update],
|
|
67
|
+
just as when using
|
|
68
|
+
[insert][google.spanner.v1.Mutation.insert], all
|
|
69
|
+
``NOT NULL`` columns in the table must be given a value.
|
|
70
|
+
This holds true even when the row already exists and will
|
|
71
|
+
therefore actually be updated.
|
|
72
|
+
|
|
73
|
+
This field is a member of `oneof`_ ``operation``.
|
|
74
|
+
replace (google.cloud.spanner_v1.types.Mutation.Write):
|
|
75
|
+
Like [insert][google.spanner.v1.Mutation.insert], except
|
|
76
|
+
that if the row already exists, it is deleted, and the
|
|
77
|
+
column values provided are inserted instead. Unlike
|
|
78
|
+
[insert_or_update][google.spanner.v1.Mutation.insert_or_update],
|
|
79
|
+
this means any values not explicitly written become
|
|
80
|
+
``NULL``.
|
|
81
|
+
|
|
82
|
+
In an interleaved table, if you create the child table with
|
|
83
|
+
the ``ON DELETE CASCADE`` annotation, then replacing a
|
|
84
|
+
parent row also deletes the child rows. Otherwise, you must
|
|
85
|
+
delete the child rows before you replace the parent row.
|
|
86
|
+
|
|
87
|
+
This field is a member of `oneof`_ ``operation``.
|
|
88
|
+
delete (google.cloud.spanner_v1.types.Mutation.Delete):
|
|
89
|
+
Delete rows from a table. Succeeds whether or
|
|
90
|
+
not the named rows were present.
|
|
91
|
+
|
|
92
|
+
This field is a member of `oneof`_ ``operation``.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
class Write(proto.Message):
|
|
96
|
+
r"""Arguments to [insert][google.spanner.v1.Mutation.insert],
|
|
97
|
+
[update][google.spanner.v1.Mutation.update],
|
|
98
|
+
[insert_or_update][google.spanner.v1.Mutation.insert_or_update], and
|
|
99
|
+
[replace][google.spanner.v1.Mutation.replace] operations.
|
|
100
|
+
|
|
101
|
+
Attributes:
|
|
102
|
+
table (str):
|
|
103
|
+
Required. The table whose rows will be
|
|
104
|
+
written.
|
|
105
|
+
columns (MutableSequence[str]):
|
|
106
|
+
The names of the columns in
|
|
107
|
+
[table][google.spanner.v1.Mutation.Write.table] to be
|
|
108
|
+
written.
|
|
109
|
+
|
|
110
|
+
The list of columns must contain enough columns to allow
|
|
111
|
+
Cloud Spanner to derive values for all primary key columns
|
|
112
|
+
in the row(s) to be modified.
|
|
113
|
+
values (MutableSequence[google.protobuf.struct_pb2.ListValue]):
|
|
114
|
+
The values to be written. ``values`` can contain more than
|
|
115
|
+
one list of values. If it does, then multiple rows are
|
|
116
|
+
written, one for each entry in ``values``. Each list in
|
|
117
|
+
``values`` must have exactly as many entries as there are
|
|
118
|
+
entries in
|
|
119
|
+
[columns][google.spanner.v1.Mutation.Write.columns] above.
|
|
120
|
+
Sending multiple lists is equivalent to sending multiple
|
|
121
|
+
``Mutation``\ s, each containing one ``values`` entry and
|
|
122
|
+
repeating [table][google.spanner.v1.Mutation.Write.table]
|
|
123
|
+
and [columns][google.spanner.v1.Mutation.Write.columns].
|
|
124
|
+
Individual values in each list are encoded as described
|
|
125
|
+
[here][google.spanner.v1.TypeCode].
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
table: str = proto.Field(
|
|
129
|
+
proto.STRING,
|
|
130
|
+
number=1,
|
|
131
|
+
)
|
|
132
|
+
columns: MutableSequence[str] = proto.RepeatedField(
|
|
133
|
+
proto.STRING,
|
|
134
|
+
number=2,
|
|
135
|
+
)
|
|
136
|
+
values: MutableSequence[struct_pb2.ListValue] = proto.RepeatedField(
|
|
137
|
+
proto.MESSAGE,
|
|
138
|
+
number=3,
|
|
139
|
+
message=struct_pb2.ListValue,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
class Delete(proto.Message):
|
|
143
|
+
r"""Arguments to [delete][google.spanner.v1.Mutation.delete] operations.
|
|
144
|
+
|
|
145
|
+
Attributes:
|
|
146
|
+
table (str):
|
|
147
|
+
Required. The table whose rows will be
|
|
148
|
+
deleted.
|
|
149
|
+
key_set (google.cloud.spanner_v1.types.KeySet):
|
|
150
|
+
Required. The primary keys of the rows within
|
|
151
|
+
[table][google.spanner.v1.Mutation.Delete.table] to delete.
|
|
152
|
+
The primary keys must be specified in the order in which
|
|
153
|
+
they appear in the ``PRIMARY KEY()`` clause of the table's
|
|
154
|
+
equivalent DDL statement (the DDL statement used to create
|
|
155
|
+
the table). Delete is idempotent. The transaction will
|
|
156
|
+
succeed even if some or all rows do not exist.
|
|
157
|
+
"""
|
|
158
|
+
|
|
159
|
+
table: str = proto.Field(
|
|
160
|
+
proto.STRING,
|
|
161
|
+
number=1,
|
|
162
|
+
)
|
|
163
|
+
key_set: keys.KeySet = proto.Field(
|
|
164
|
+
proto.MESSAGE,
|
|
165
|
+
number=2,
|
|
166
|
+
message=keys.KeySet,
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
insert: Write = proto.Field(
|
|
170
|
+
proto.MESSAGE,
|
|
171
|
+
number=1,
|
|
172
|
+
oneof="operation",
|
|
173
|
+
message=Write,
|
|
174
|
+
)
|
|
175
|
+
update: Write = proto.Field(
|
|
176
|
+
proto.MESSAGE,
|
|
177
|
+
number=2,
|
|
178
|
+
oneof="operation",
|
|
179
|
+
message=Write,
|
|
180
|
+
)
|
|
181
|
+
insert_or_update: Write = proto.Field(
|
|
182
|
+
proto.MESSAGE,
|
|
183
|
+
number=3,
|
|
184
|
+
oneof="operation",
|
|
185
|
+
message=Write,
|
|
186
|
+
)
|
|
187
|
+
replace: Write = proto.Field(
|
|
188
|
+
proto.MESSAGE,
|
|
189
|
+
number=4,
|
|
190
|
+
oneof="operation",
|
|
191
|
+
message=Write,
|
|
192
|
+
)
|
|
193
|
+
delete: Delete = proto.Field(
|
|
194
|
+
proto.MESSAGE,
|
|
195
|
+
number=5,
|
|
196
|
+
oneof="operation",
|
|
197
|
+
message=Delete,
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
__all__ = tuple(sorted(__protobuf__.manifest))
|