我在GAE上使用python。
我有一个查询,我需要匹配一个字段与来自列表的值。 我的实体的样子:gae ndb查询多个值
class TimeTableChange(ndb.Model):
"""A Change entry."""
details = ndb.StringProperty()
class_label = ndb.StringProperty()
class_id = ndb.IntegerProperty()
year = ndb.IntegerProperty()
month = ndb.IntegerProperty()
day_of_month = ndb.IntegerProperty()
hour = ndb.IntegerProperty()
type = ndb.StringProperty()
ts = ndb.IntegerProperty()
我想运行一个查询,看起来像(MySQL的像例如):
select * from TimeTableChange
where year = 2017 and month = 8 and day_of_month = 12 and class_id IN [12,34,67]
列表[12,34,67]只是一个例如,列表可能是空的或包含N个整数。我如何创建正确的ndb查询?
对于年/月/ DAY_OF_MONTH我用
query = query.filter(ndb.AND(TimeTableChange.year == tomorrow.year,
TimeTableChange.month == tomorrow.month,
TimeTableChange.day_of_month == tomorrow.day))
,它工作正常。现在我需要匹配“类标识码”对一个列表
那么int列表呢?它在查询中如何表示? – balderman
我更新了答案,我认为这将适用于int。 –