Skip to content

Commit fe20d41

Browse files
chore(spanner): Issue#1163 Remove dependency of spanner dbapi from spanner_v1 (#1164)
- Moved BatchTransactionId dataclass from spanner_dbapi to spanner_v1.transactions Co-authored-by: Sri Harsha CH <57220027+harshachinta@users.noreply.github.com>
1 parent 9609ad9 commit fe20d41

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

google/cloud/spanner_dbapi/partition_helper.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import pickle
2020
import base64
2121

22+
from google.cloud.spanner_v1 import BatchTransactionId
23+
2224

2325
def decode_from_string(encoded_partition_id):
2426
gzip_bytes = base64.b64decode(bytes(encoded_partition_id, "utf-8"))
@@ -33,13 +35,6 @@ def encode_to_string(batch_transaction_id, partition_result):
3335
return str(base64.b64encode(gzip_bytes), "utf-8")
3436

3537

36-
@dataclass
37-
class BatchTransactionId:
38-
transaction_id: str
39-
session_id: str
40-
read_timestamp: Any
41-
42-
4338
@dataclass
4439
class PartitionId:
4540
batch_transaction_id: BatchTransactionId

google/cloud/spanner_v1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
from .types.type import TypeAnnotationCode
6565
from .types.type import TypeCode
6666
from .data_types import JsonObject
67+
from .transaction import BatchTransactionId
6768

6869
from google.cloud.spanner_v1 import param_types
6970
from google.cloud.spanner_v1.client import Client
@@ -147,4 +148,5 @@
147148
# google.cloud.spanner_v1.services
148149
"SpannerClient",
149150
"SpannerAsyncClient",
151+
"BatchTransactionId",
150152
)

google/cloud/spanner_v1/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from google.cloud.spanner_admin_database_v1 import RestoreDatabaseRequest
4141
from google.cloud.spanner_admin_database_v1 import UpdateDatabaseDdlRequest
4242
from google.cloud.spanner_admin_database_v1.types import DatabaseDialect
43-
from google.cloud.spanner_dbapi.partition_helper import BatchTransactionId
43+
from google.cloud.spanner_v1.transaction import BatchTransactionId
4444
from google.cloud.spanner_v1 import ExecuteSqlRequest
4545
from google.cloud.spanner_v1 import Type
4646
from google.cloud.spanner_v1 import TypeCode

google/cloud/spanner_v1/transaction.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
from google.cloud.spanner_v1 import RequestOptions
3737
from google.api_core import gapic_v1
3838
from google.api_core.exceptions import InternalServerError
39+
from dataclasses import dataclass
40+
from typing import Any
3941

4042

4143
class Transaction(_SnapshotBase, _BatchBase):
@@ -554,3 +556,10 @@ def __exit__(self, exc_type, exc_val, exc_tb):
554556
self.commit()
555557
else:
556558
self.rollback()
559+
560+
561+
@dataclass
562+
class BatchTransactionId:
563+
transaction_id: str
564+
session_id: str
565+
read_timestamp: Any

0 commit comments

Comments
 (0)