File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1511,6 +1511,8 @@ def delete_data_with_partitioned_dml(instance_id, database_id):
15111511def update_with_batch_dml (instance_id , database_id ):
15121512 """Updates sample data in the database using Batch DML. """
15131513 # [START spanner_dml_batch_update]
1514+ from google .rpc .code_pb2 import OK
1515+
15141516 # instance_id = "your-spanner-instance"
15151517 # database_id = "your-spanner-db-id"
15161518
@@ -1531,7 +1533,13 @@ def update_with_batch_dml(instance_id, database_id):
15311533 )
15321534
15331535 def update_albums (transaction ):
1534- row_cts = transaction .batch_update ([insert_statement , update_statement ])
1536+ status , row_cts = transaction .batch_update ([insert_statement , update_statement ])
1537+
1538+ if status .code != OK :
1539+ # Do handling here.
1540+ # Note: the exception will still be raised when
1541+ # `commit` is called by `run_in_transaction`.
1542+ return
15351543
15361544 print ("Executed {} SQL statements using Batch DML." .format (len (row_cts )))
15371545
You can’t perform that action at this time.
0 commit comments