Skip to content

Change datastore quickstart sample to create a task. #561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions datastore/api/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,21 @@ def run_quickstart():
# Instantiates a client
datastore_client = datastore.Client()

# The kind of the entity to retrieve
# The kind for the new entity
kind = 'Task'
# The name/ID of the entity to retrieve
# The name/ID for the new entity
name = 'sampletask1'
# The Datastore key for the entity
# The Cloud Datastore key for the new entity
task_key = datastore_client.key(kind, name)

# Retrieves the entity
task = datastore_client.get(task_key)
# Prepares the new entity
task = datastore.Entity(key=task_key)
task['description'] = 'Buy milk'

print('Fetched task: {}'.format(task.key.name))
# Saves the entity
datastore_client.put(task)

print('Saved {}: {}'.format(task.key.name, task['description']))
# [END datastore_quickstart]


Expand Down