Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active August 24, 2016 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/a9a08896cd22a571af5924a5e45f6c13 to your computer and use it in GitHub Desktop.
Save kurozumi/a9a08896cd22a571af5924a5e45f6c13 to your computer and use it in GitHub Desktop.
【Python】peeweeで部分一致のAND検索
import Page
import operator
clauses = [
(Page.title.contains("hoge")),
(Page.title.contains("fuga"))
]
Page.select().where(reduce(operator.and_, clauses))
"""
SELECT * FROM page WHERE (title LIKE '%hoge%' AND title LIKE '%huga%')
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment