Matching substrings of a list from peewee(SQL)
<p>Say I have a list <code>str_list</code>, and now I want to get all entries from a table which matches any substring in the list. What's the correct way to do this? So I checked the operators provided by peewee, and there doesn't seem to be a easy way to do this.  Looks like <code>.contains(substr)</code> is the way to go with, but you have to query the database multiple times. Is there a better way to do this?</p>

<p>You can:</p>

<pre><code>import operator

class MyModel(Model):
    field_to_check = TextField()

big_expression = reduce(operator.or_, [MyModel.field_to_check.contains(s) for s in str_list])
query = MyModel.select().where(big_expression)
</code></pre>

python sql database peewee