[google-appengine] Re: How to match in query?

2009-01-16 Thread Nick Johnson

If all you want to do is retrieve the entity with a specific key,
Person.get(key) is much faster and simpler.

-Nick Johnson

On Jan 16, 6:24 am, Alexander Kojevnikov 
wrote:
> > I am messing with google app engine queries being very new to it
> > how can we match a string with __key__
> > 'SELECT * FROM Person WHERE __key__=:bkey', bkey=str(value)
> > This query is not working
> > What is wrong with this?
>
> You need to pass an instance of db.Key class as a parameter.
>
> Is 'value' a string representation of the key? If so, the code will
> look like this:
>
> query = db.GqlQuery('SELECT * FROM Person '
>                     'WHERE __key__ = :bkey',
>                     bkey=db.Key(value))
>
> See 
> alsohttp://code.google.com/appengine/docs/datastore/queriesandindexes.htm...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: How to match in query?

2009-01-15 Thread Alexander Kojevnikov

> I am messing with google app engine queries being very new to it
> how can we match a string with __key__
> 'SELECT * FROM Person WHERE __key__=:bkey', bkey=str(value)
> This query is not working
> What is wrong with this?
>
You need to pass an instance of db.Key class as a parameter.

Is 'value' a string representation of the key? If so, the code will
look like this:

query = db.GqlQuery('SELECT * FROM Person '
'WHERE __key__ = :bkey',
bkey=db.Key(value))

See also 
http://code.google.com/appengine/docs/datastore/queriesandindexes.html#Queries_on_Keys
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---