Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 1.39 KB

File metadata and controls

59 lines (45 loc) · 1.39 KB

Getting started with Cloud Datastore

Note

If you just want to kick the tires, you might prefer :doc:`datastore-quickstart`.

Creating a project

Enabling the API

Now that you created a project, you need to turn on the Cloud Datastore API. This is sort of like telling Google which services you intend to use for this project.

  • Click on APIs & Auth on the left hand side, and scroll down to where it says "Google Cloud Datastore API".
  • Click the "Off" button on the right side to turn it into an "On" button.

Enabling a service account

Add some data to your dataset

Open a Python console and...

>>> from gcloud import datastore
>>> datastore.set_defaults()
>>> from gcloud.datastore.query import Query
>>> list(Query(kind='Person').fetch())
[]
>>> from gcloud.datastore.entity import Entity
>>> from gcloud.datastore.key import Key
>>> entity = Entity(key=Key('Person'))
>>> entity['name'] = 'Your name'
>>> entity['age'] = 25
>>> entity.save()
>>> list(Query(kind='Person').fetch())
[<Entity{...} {'name': 'Your name', 'age': 25}>]

And that's it!

Next, take a look at the complete :doc:`datastore-api`.