def python_partial_match(needle,key,haystack):
for item in haystack.select():
if needle in str(getattr(item,key,None)):
yield item
for result in python_partial_match("20","phone_number",UserModelClass):
print "GOT RESULT:",result
,但它的將是大數據集,我認爲
或者我認爲你可以做的很慢像
PostgresqlDatabase.register_ops({'::', '::'})
@Node.extend()
def cast(self, as_type):
return Expression(self, '::', SQL(as_type))
DataModel.select().where(DataModel.integer_col.cast('str').contains("20"))
也許...我沒有測試,鑄造thi NG ......(見http://docs.peewee-orm.com/en/latest/peewee/api.html?highlight=cast#Node.extend)
實際上它看起來像有在劇場一個內置cast
Postgres的看到http://docs.peewee-orm.com/en/latest/peewee/playhouse.html?highlight=cast#cast
不幸的是,這些建議並沒有爲我工作,但我確實找到了一種方法 – user964491