5

I am using Google App Engine's datastore and wants to retrieve an entity whose key value is written as

ID/Name

id=1

Can anyone suggest me a GQL query to view that entity in datastore admin console and also in my python program?

systempuntoout
  • 71,966
  • 47
  • 171
  • 241
niteshb
  • 2,599
  • 2
  • 17
  • 16

2 Answers2

5

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

entity = YourModel.get_by_id(1)

From Datastore viewer you should use the KEY function:

SELECT * FROM YourModel WHERE __key__ = KEY('YourModel',1)
systempuntoout
  • 71,966
  • 47
  • 171
  • 241
0

An application can retrieve a model instance for a given Key using the get() function.

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))

I'm not sure how to return a specific entity in the admin console.

garnertb
  • 9,454
  • 36
  • 38
  • thanx buddy it worked but still I cannot use this in datastore admin console. do you have any idea for that? – niteshb Feb 22 '11 at 12:37