这看起来应该是一个简单的问题。但the docs似乎没有回答。使用他们的例子,我想这样做:ndb查询部分字符串匹配
Account.query(Account.title == "best")
除我想匹配部分字符串以及。因此,在这种情况下:
acct = Account(title="the best account in the world")
的NDB查询与参数“最佳”将匹配acct
。
我目前看到的唯一选择是循环穿过Account.query()
,并在python中将每个title
与re.search
模块进行匹配。这似乎不是一个好的解决方案。
更新:我还在看gql
。这样做:
acct = ndb.gql('SELECT * from Account WHERE title LIKE '%best%')
返回Parse Error: Invalid WHERE Condition at symbol LIKE
GQL不是SQL。 –