diff --git a/spanner/cloud-client/snippets.py b/spanner/cloud-client/snippets.py index 9c0eb3d64b9e..0837d7aca512 100644 --- a/spanner/cloud-client/snippets.py +++ b/spanner/cloud-client/snippets.py @@ -1407,6 +1407,13 @@ def query_data_with_timestamp_parameter(instance_id, database_id): database = instance.database(database_id) example_timestamp = datetime.datetime.utcnow().isoformat() + "Z" + # [END spanner_query_with_timestamp_parameter] + # Avoid time drift on the local machine. + # https://github.com/GoogleCloudPlatform/python-docs-samples/issues/4197. + example_timestamp = ( + datetime.datetime.utcnow() + datetime.timedelta(days=1) + ).isoformat() + "Z" + # [START spanner_query_with_timestamp_parameter] param = { 'last_update_time': example_timestamp } diff --git a/spanner/cloud-client/snippets_test.py b/spanner/cloud-client/snippets_test.py index 0ec3ef42b7c0..49a11dce91a4 100644 --- a/spanner/cloud-client/snippets_test.py +++ b/spanner/cloud-client/snippets_test.py @@ -363,9 +363,6 @@ def test_query_data_with_string(capsys): def test_query_data_with_timestamp_parameter(capsys): - # Wait 5 seconds to avoid a time drift issue for the next query: - # https://github.com/GoogleCloudPlatform/python-docs-samples/issues/4197. - time.sleep(5) snippets.query_data_with_timestamp_parameter(INSTANCE_ID, DATABASE_ID) out, _ = capsys.readouterr() assert 'VenueId: 4, VenueName: Venue 4, LastUpdateTime:' in out