GQL queries of Datastore via command-line tool like gcloud, bq, other?

2,058 views
Skip to first unread message

Brian Miller

unread,
Jun 30, 2017, 5:09:27 PM6/30/17
to Google App Engine

Hello,

I have been using the "Datastore" feature with Google App Engine,
and querying data via

(1) Java-based application our team wrote, which runs in deployed Google App Engine environment
     (Query by kind) and

I recently started experimenting with the command-line tools provided
with the google-cloud-sdk, such as google-cloud-sdk/bin/gcloud

I noticed that there are commands:

gcloud datastore create-indexes index.yaml
gcloud datastore cleanup-indexes index.yaml

I was hoping there might be a way to use gcloud (or other command-line tool)
to perform GQL queries like "SELECT * FROM MyDatastoreName"

I also noticed there is another tool called "bq" for BigQuery,
but we do not have datasets in BigQuery.

Is there an existing command-line tool for querying datastores,
or would I need to write my own?

Thanks,

Brian Miller


Jordan (Cloud Platform Support)

unread,
Jul 3, 2017, 5:13:52 PM7/3/17
to Google App Engine
Since the Google Cloud Datastore is a highly-scalable NoSQL non-relational database, interactions with the Datastore are optimized for direct API calls, and not for SQL-like languages such as GQL. 

As explained in the documentation, GQL is a limited SQL query language which can be used for SQL-like queries on the Datastore. GQL is not available in all Datastore API languages, but it is available for the Java Client Library. The Cloud Console GQL console should only be used for simple/quick and board overview of your data.

If you are instead looking for SQL support for a highly-scalable database, I would recommend looking into Google Cloud Spanner instead.  

Brian Miller

unread,
Jul 5, 2017, 3:30:27 PM7/5/17
to Google App Engine

Thanks for the reply, Jordan.

I also saw there is a separate group for discussions about Google Cloud Datastore.
I probably should have posted there first / instead of in this group.

We do have existing Java code in our server (deployed to a Google App Engine environment)
which accesses our datastores via Java libraries.

We do use the Cloud Console, mostly in a limited and ad hoc manner, as needed
for some tasks as part of DevOps, debugging, testing, etc..

I was just curious about a possible existing command-line tool which might
(a) have advantages over the Cloud Console, (b) be used as a sanity check for comparison
with the results we are seeing from our Java code. 

Thanks again for your input,

Brian

Jordan (Cloud Platform Support)

unread,
Jul 6, 2017, 9:45:20 AM7/6/17
to Google App Engine
There is currently no commandline tool for performing GQL queries against the Datastore as the Datastore is meant to be a No-SQL database (unlike BigQuery which supports SQL and has its own commandline tool for performing SQL queries). 

Such a tool would simply run the available API Client Libraries previously discussed to perform the queries. If you require such a tool, you could quickly put one together that meets your needs using the Client Libraries.

If you instead wish to request one to be made by our engineering team, you can fill out a feature request explaining the business justification for having such a tool. 

Shinichi Nishimura

unread,
Aug 11, 2017, 9:02:52 AM8/11/17
to Google App Engine
Hi,

I have same issue and could't found a command-line tool for Datastore.
So I have been developing a command-line tool:
https://github.com/nshmura/dsio

It would be nice, if you check this tool.
Thanks.


2017年7月6日木曜日 4時30分27秒 UTC+9 Brian Miller:
Reply all
Reply to author
Forward
0 new messages