Skip to content

Commit 9b5b1bb

Browse files
committed
Change datastore quickstart sample to create a task.
1 parent 02f7e56 commit 9b5b1bb

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

datastore/api/quickstart.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,21 @@ def run_quickstart():
2323
# Instantiates a client
2424
datastore_client = datastore.Client()
2525

26-
# The kind of the entity to retrieve
26+
# The kind for the new entity
2727
kind = 'Task'
28-
# The name/ID of the entity to retrieve
28+
# The name/ID for the new entity
2929
name = 'sampletask1'
30-
# The Datastore key for the entity
30+
# The Cloud Datastore key for the new entity
3131
task_key = datastore_client.key(kind, name)
3232

33-
# Retrieves the entity
34-
task = datastore_client.get(task_key)
33+
# Prepares the new entity
34+
task = datastore.Entity(key=task_key)
35+
task['description'] = 'Buy milk'
3536

36-
print('Fetched task: {}'.format(task.key.name))
37+
# Saves the entity
38+
datastore_client.put(task)
39+
40+
print('Saved {}: {}'.format(task.key.name, task['description']))
3741
# [END datastore_quickstart]
3842

3943

0 commit comments

Comments
 (0)