【Python】peeweeで部分一致のOR検索する方法です。
サンプリコードは以下の通りです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Page | |
import operator | |
clauses = [ | |
(Page.title.contains("hoge")), | |
(Page.title.contains("fuga")) | |
] | |
Page.select().where(reduce(operator.or_, clauses)) | |
""" | |
SELECT * FROM page WHERE (title LIKE '%hoge%' OR title LIKE '%huga%') | |
""" |