Skip to content

Commit 70a0a61

Browse files
committed
Minor fixes.
1 parent 1cbb517 commit 70a0a61

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

spanner/cloud-client/snippets.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -510,16 +510,16 @@ def insert_data_with_timestamp(instance_id, database_id):
510510

511511

512512
# [START spanner_add_timestamp_column]
513-
def add_timestamp_column(database_id, instance_id):
513+
def add_timestamp_column(instance_id, database_id):
514514
"""Adds a new TIMESTAMP column to the Albums table in the example database."""
515515
spanner_client = spanner.Client()
516516
instance = spanner_client.instance(instance_id)
517517

518518
database = instance.database(database_id)
519519

520-
operation = database.update_ddl(
520+
operation = database.update_ddl([
521521
'ALTER TABLE Albums ADD COLUMN LastUpdateTime TIMESTAMP '
522-
'OPTIONS(allow_commit_timestamp=true)')
522+
'OPTIONS(allow_commit_timestamp=true)'])
523523

524524
print('Waiting for operation to complete...')
525525
operation.result()
@@ -530,20 +530,20 @@ def add_timestamp_column(database_id, instance_id):
530530

531531

532532
# [START spanner_update_data_with_timestamp_column]
533-
def update_data_with_timestamp(database_id, instance_id):
533+
def update_data_with_timestamp(instance_id, database_id):
534534
"""Updates Performances tables in the database with the COMMIT_TIMESTAMP column.
535535
536536
This updates the `MarketingBudget` column which must be created before
537537
running this sample. You can add the column by running the `add_column`
538538
sample or by running this DDL statement against your database:
539539
540-
ALTER TABLE Performances ADD COLUMN MarketingBudget INT64
540+
ALTER TABLE Albums ADD COLUMN MarketingBudget INT64
541541
542542
In addition this update expects the LastUpdateTime column added by
543543
applying this DDL statement against your database:
544544
545-
ALTER TABLE Performances ADD COLUMN LastUpdateTime TIMESTAMP
546-
OPTIONS (allow_commit_timestamp=true)
545+
ALTER TABLE Albums ADD COLUMN LastUpdateTime TIMESTAMP
546+
OPTIONS(allow_commit_timestamp=true)
547547
"""
548548
spanner_client = spanner.Client()
549549
instance = spanner_client.instance(instance_id)
@@ -554,11 +554,11 @@ def update_data_with_timestamp(database_id, instance_id):
554554
batch.update(
555555
table='Albums',
556556
columns=(
557-
'SingerId', 'AlbumId', 'MarketingBudget'),
557+
'SingerId', 'AlbumId', 'MarketingBudget', 'LastUpdateTime'),
558558
values=[
559-
(1, 4, "2017-10-05", 11000, spanner.COMMIT_TIMESTAMP),
560-
(1, 19, "2017-11-02", 15000, spanner.COMMIT_TIMESTAMP),
561-
(2, 42, "2017-12-23", 7000, spanner.COMMIT_TIMESTAMP)])
559+
(1, 4, 11000, spanner.COMMIT_TIMESTAMP),
560+
(1, 19, 15000, spanner.COMMIT_TIMESTAMP),
561+
(2, 42, 7000, spanner.COMMIT_TIMESTAMP)])
562562

563563
print('Updated data.')
564564
# [END spanner_update_data_with_timestamp_column]
@@ -584,8 +584,8 @@ def query_data_with_timestamp(instance_id, database_id):
584584

585585
with database.snapshot() as snapshot:
586586
results = snapshot.execute_sql(
587-
'SELECT SingerId, AlbumId, AlbumTitle FROM Albums'
588-
'FROM Albums ORDER BY LastUpdateTime DESC')
587+
'SELECT SingerId, AlbumId, AlbumTitle FROM Albums '
588+
'ORDER BY LastUpdateTime DESC')
589589

590590
for row in results:
591591
print(u'SingerId: {}, AlbumId: {}, AlbumTitle: {}'.format(*row))

spanner/cloud-client/snippets_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,5 +265,5 @@ def _():
265265

266266
out, _ = capsys.readouterr()
267267

268-
assert 'Updated data.' in out
268+
assert 'Go, Go, Go' in out
269269

0 commit comments

Comments
 (0)