How to get an object from a key value in GQL

I use the Google App Engine datastore and want to get an object whose key value is written as

ID/Name

id=1

Can someone suggest me a GQL query to view this object in the data warehouse admin console, as well as in my python program?

+5
source share
2 answers

In your application, use the get_by_id () method of the Model class:

entity = YourModel.get_by_id(1)

From the Datastore viewer, you should use the function KEY:

SELECT * FROM YourModel WHERE __key__ = KEY('YourModel',1)
+5
source

get().

class member(db.Model):
    firstName=db.StringProperty(verbose_name='First Name',required=False)
    lastName=db.StringProperty(verbose_name='Last Name',required=False)

...

id = int(self.request.get('id'))
entity= member.get(db.Key.from_path('member', id))

, .

0

All Articles