Re: Building queries on the fly

Robert Gravina <[email protected]> Mon, 18 Sep 2006 05:31:54 +0900
Newsgroups gmane.comp.python.quotient.dev
Message-ID <[email protected]>
> I'll tell you how to do this, but I will caution you: building  
> queries dynamically can easily result in queries which are not  
> indexed, or have pathological query times.  While this is not great  
> in any datbase, in Axiom it's particularly bad because the rest of  
> your program is going to be totally stopped waiting for the rest of  
> that query to execute.

Thanks for the warning.

> We should be building more support into Axiom some time in the next  
> year for easily determining if your query is indexable and whether  
> it's going to be very expensive to run before executing it, but  
> until then you should familiarize yourself with the indexing rules  
> that SQLite uses.

Ah great, I'll do that, and then hopefully can build my query  
conditions in a sensible order.

> This is equivalent to
>
>  conditions = []
>  conditions.append(MyItem.name == "foo")
>  conditions.append(MyItem.owner == MyOwnerItem.storeID)
>  conditions.append(MyOwnerItem.likes != "icecream")
>  self.store.query(MyItem, AND(*conditions))
>
> Hopefully that explains how to do what you want :).
>

Once again, Glyph to the rescue! I didn't know about that "*" syntax  
in Python (although I have seen it), and being able to give lists as  
arguments to functions like that. Thanks.

Robert