Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 1.37 KB

File metadata and controls

59 lines (45 loc) · 1.37 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
>>> dataset = datastore.get_dataset(
>>>     '<your-project-id-here',
>>>     '<the e-mail address you copied here>',
>>>     '/path/to/<your project>.key')
>>> dataset.query().fetch()
[]
>>> entity = dataset.entity('Person')
>>> entity['name'] = 'Your name'
>>> entity['age'] = 25
>>> entity.save()
>>> dataset.query('Person').fetch()
[<Entity{...} {'name': 'Your name', 'age': 25}>]

And that's it!

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