Re: [SQLObject] Looking for selection hints
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Ian B. <ia...@co...> - 2003-10-26 23:14:28
|
On Sunday, October 26, 2003, at 04:48 PM, Frank Barknecht wrote:
> I could need a little help with understanding how to build
> SQLObject selections dynamically.
>
> So far, I have a dictionary that describes the criteria to search the
> DB. Keys are my Columns, values are lists of search words. Like this:
>
> {'title': ['rock'], 'format': ['cd'], 'artist': ['strokes', 'the']}
query = None
for colName, ops in above_dict.items():
for op in ops:
subquery = LIKE(getattr(Product.q, colName), op)
if query:
query = AND(query, subquery)
else:
query = subquery
It might be nice if Product.q allowed dictionary access too. And if
AND(anything, None) return anything. But this will work too.
--
Ian Bicking | ia...@co... | http://blog.ianbicking.org
|