I know that you can do :
result = db((db.xxx.tag==tag) (db.xxx.status==status)).select()
But i don't know how to generate the condition, one by one...
On 10 fév, 23:10, gbs grosbe...@gmail.com wrote:
Hi,
i have search posts on this group, but i don't have found the solution
of my
Oh? you think?
Ok i will test, thanks a lot!
On 10 fév, 23:18, Bruno Rocha rochacbr...@gmail.com wrote:
*queries=[]*
*if arg1 == x: queries.append(db.table.field == x)*
*if arg2 == y: queries.append(db.table.otherfield == y)*
*# many conditions here*
*query = reduce(lambda
You could do something like:
query = db.mytable.id 0
if tag:
query = db.mytable.tag == tag
if status:
query = db.mytable.status == status
Anthony
On Friday, February 10, 2012 5:10:01 PM UTC-5, gbs wrote:
Hi,
i have search posts on this group, but i don't have found the solution
sql = db
-- if tag :
sql = sql(db.mytable.tag = xxx)
-- if status:
sql = sql(db.mytable.status = xxx)
result = sql.select()
On Fri, Feb 10, 2012 at 2:25 PM, Anthony abasta...@gmail.com wrote:
You could do something like:
query = db.mytable.id 0
if tag:
query = db.mytable.tag ==
Thanks to all.
I have test the first answer, from Bruno..
It's work!
Thanks a lot, i'm searching/reading during a long time!
I will test the others solutions, why i think they are more simple/
comprehensible for me :$
Best regards
ps : sorry for the language
On 10 fév, 23:18, Bruno Rocha
On Friday, February 10, 2012 5:35:50 PM UTC-5, Detectedstealth wrote:
sql = db
-- if tag :
sql = sql(db.mytable.tag = xxx)
-- if status:
sql = sql(db.mytable.status = xxx)
result = sql.select()
Yes, that's nice too. It works because the Set object is callable, and
calling it adds a
I have try the solution of anthony, but i don't have the skill in
python to success..
(some error with 'Rows' object has no attribute 'select', etc ;)
But it's my fault,
Thanks again
On 10 fév, 23:43, gbs grosbe...@gmail.com wrote:
Thanks to all.
I have test the first answer, from Bruno..
On Friday, February 10, 2012 6:19:09 PM UTC-5, gbs wrote:
I have try the solution of anthony, but i don't have the skill in
python to success..
(some error with 'Rows' object has no attribute 'select', etc ;)
Once the query has been built, this should work:
rows = db(query).select()
Yes, thanks, you'r right.
With you'r method, it's simple ;)
And you can make AND condition :
query = db.mytable.tag == tag
OR condition :
query |= db.mytable.tag == tag
It's exactly what i'm seeking!
You'r solution, and Bruno's one, are perfect,
I hope that can help someone else,
Have a nice
9 matches
Mail list logo