Python
0.02.2
Getting started#
The gcloud library is pip install-able:
$ pip install gcloud
If you have trouble installing pycrypto or pyopenssl (and you’re on Ubuntu), you can try install the precompiled packages:
$ sudo apt-get install python-crypto python-openssl
If you want to install everything with pip, try installing the dev packages beforehand:
$ sudo apt-get install python-dev libssl-dev
If you want to install gcloud-python from source, you can clone the repository from GitHub:
$ git clone git://github.com/GoogleCloudPlatform/gcloud-python.git
$ cd gcloud-python
$ python setup.py install
Cloud Datastore#
Google Cloud Datastore is a fully managed, schemaless database for storing non-relational data.
from gcloud import datastore
dataset = datastore.get_dataset(
'<your-project-id>',
'<service-account-email>',
'/path/to/your/key')
entity = dataset.entity('Person')
entity['name'] = 'Your name'
entity['age'] = 25
entity.save()
Cloud Storage#
Google Cloud Storage allows you to store data on Google infrastructure.
from gcloud import storage
bucket = storage.get_bucket(
'<your-bucket-name>',
'<your-project-id>',
'<service-account-email>',
'/path/to/your/key')
key = bucket.new_key('my-test-file.txt')
key = key.upload_contents_from_string('this is test content!')