> It took me a long time to figure out a way to do this with SO:
> result = Question.select(Question.q.question.contains('tree'))
> 
<snip>
> Now it looks as though it is OK to use SQLBuilder, or at least other
> people use it or recommend using it.  And I've learned a completely
> new way of searching for stuff, thanks to Leandro.
> 
<snip>

Both approaches are totally valid, which is best depends on your
resource allocation, programmer speed vs db needs. And that depends on a
good analysis of the job! 

What Leandro used is such a common idiom in python web programming that
it becomes a natural thing to do if you are used to using list
comprehensions on your db output. If you are new to python, they seem a
little strange, but if you are likely doing such a thing anyway, then it
seems like extra work to write the sql. Example:

things = [ filter_function(thing) for thing in Things.select() ]

So either:
- use put the regular expression in the sql statement and the db does
the searching: 
- this is likely faster and lower db throughput

or:
- you get everything from the db with the incredibly simple ORM sytax
and run a list comprehension on it later to filter out what you want
- more flexible and easy syntax, *and* you don't even have to bind the
methodology to your table or column name ( especially if using SA )
- further, the filter_function might do a lot more than what you can do
in an sql statement without getting really ugly

Hope that helps,
Iain


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to