Nicky Feller
Nicky Feller

Reputation: 3889

Delete entity in google datastore in python

I want to delete/modify an entity in the google cloud datastore based on an email.

email = '[email protected]'
query = client.query('email', '=', email)
# delete this entity if it exists??

Now that I have this query, how can I go about deleting this entity?

Upvotes: 1

Views: 3894

Answers (1)

Dan McGrath
Dan McGrath

Reputation: 42008

next_entity = query.fetch()
client.delete(next_entity.key)

If you're only deleting the entity and don't need anything other than the key, consider doing a keys_only query to avoid reading data you don't care about.

Upvotes: 5

Related Questions