python - Querying a many-to-many relationship in SQLAlchemy -


i have pretty standard many-to-many relationship, similar blog -> keyword relationship in orm tutorial.

i query list of keywords, returning blog posts of them match. however, can't work out if there simple way this. if add multiple filters, repeatedly doing

.filter(blog.keywords.any(keyword.name == 'keyword'))  

then 'and'/'exists' query, such posts have keywords returned. there simple way 'or' query, or need work using join().

thanks help; can't work out whether missing something.

i think want

.filter(blog.keywords.any(keyword.name.in_(['keyword1', 'keyword2', ...]))) 

i'm using http://www.sqlalchemy.org/docs/05/ormtutorial.html#common-filter-operators reference


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -