Skip to content

Instantly share code, notes, and snippets.

@proppy
Created January 30, 2014 20:41
Show Gist options
  • Save proppy/8718248 to your computer and use it in GitHub Desktop.
Save proppy/8718248 to your computer and use it in GitHub Desktop.
>>> from gcloud import datastore
>>> dataset = datastore.dataset('foo')
>>> entity = dataset.entity('Foo', 1) # complete key
>>> entity.key
('Foo', 1L)
>>> entity.save() # or dataset.upsert(entity)
>>> entity = dataset.entity('Foo') # incomplete key
>>> entity.key
('Foo',)
>>> entity.save() # or dataset.upsert(entity)
>>> entity.key
('Foo', 1001L) # auto allocated ids
>>> entity = dataset.entity('Parent', 'name', 'Foo', 2)
>>> entity.key
('Parent', 'name', 'Foo', 2)
>>> entity.save() # or dataset.upsert(entity)
>>> dataset.lookup([('Parent', 'name', 'Foo', 2), ('Foo', 1)])
[Entity('Parent', 'name', 'Foo', 2), ('Foo', 1)]
@jgeewax
Copy link

jgeewax commented Jan 30, 2014

(Adding a back-reference: googleapis/google-cloud-python#3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment