Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active Aug 24, 2016
Embed
What would you like to do?
【Python】peeweeで部分一致のOR検索
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%')
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment