Google app engine or query (python)

試著忘記壹切 提交于 2020-01-14 12:57:48

问题


Can anyone share your approach for doing a 'or' query in app-engine?

Let say I have

class A_db_model(db.Model):
 valueA = db.ListProperty(basestring)

in valueA I have

aaa
aaa, bbb
bbb
ccc

I would like to return result of if the valueA match 'aaa' or 'bbb' and return not duplicated result.


回答1:


Try this?

A_db_model.all().filter('valueA IN', ['aaa', 'bbb'])

or the equivalent GQL:

GqlQuery('SELECT * FROM A_db_model WHERE valueA IN :1', ['aaa', 'bbb'])



回答2:


The two main problems with @Amber's approach is that it is slow as it basically runs a query for each value behind the scenes and it maxes out at 30 values to query for. I just wrote a blog post about this question. It explains the best scalable way to basically do an OR query with app engine. You can use a separate entity to make this happen. See the post for details.

http://tornblue.com/post/11310830291/app-engine-how-to-do-an-efficient-or-query



来源:https://stackoverflow.com/questions/3714972/google-app-engine-or-query-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!