python-2.7google-cloud-platformgoogle-cloud-datastoregcloud-pythongoogle-cloud-python

How to do a GQL query (using gcloud-python)


I have a collection of Entities of one kind. I need to extract the distinct values of one property, named p, of these Entities.

In GQL, I would do:

SELECT DISTINCT p from kind

However in the gcloud-python library GQL queries aren't implemented yet (see issue-304).

How should I do that with the tools currently available in gcloud-python ? I'm aware of a "group-by" workaround, yet the performances are terrible.


Solution

  • gcloud-python currently doesn't provide a way for you to do a string GQL query (source), however it seems you can use the group_by field in the Cloud Datastore API to accomplish the same thing.

    References: