Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python how to get all kind names in google cloud datastore

I am wondering how to retrieve all kind names that are stored in the google cloud datastore in Python. I am thinking of using a query,

client = datastore.Client()
query = client.query()
results = query.fetch()

but it only gets all the entities stored by the default client. So how to get all the kinds' names in this case?

like image 809
daiyue Avatar asked Oct 26 '25 17:10

daiyue


1 Answers

You can use a kind metadata query to fetch the kind names.

If you're using the Google Cloud Python library, it would look like:

query = client.query(kind='__kind__')
query.keys_only()

kinds = [entity.key.id_or_name for entity in query.fetch()]
like image 107
Ed Davisson Avatar answered Oct 28 '25 06:10

Ed Davisson