[storm] Building large queries with Storm ORM

nhytro-python at web.de nhytro-python at web.de
Fri Oct 26 08:39:25 BST 2007


Thanks for the reply James


Great! I think thats exactly what I meant. But just to be sure:

1. I gather all the field values that need to be searched in the same table and append them to a list (conditions.append(In(Table.field1, field1_values))
2. A join to search all the different fields in their respective tables ( results = store.find(Table, And(*conditions))

What does "In(Table.field1, field1_values)" exactly do? I did not find the "In" inthe docs, the looks like a table name to field name mapping 
The * is a wildcard I presume, in this case its the the SQL equivalent, is it?


Did I get that right? For the future, could you point me to the docs where I can read up on Storm's expression logic?  


Thanks a bunch!


> -----Ursprüngliche Nachricht-----
> Von: "James Henstridge" <james at jamesh.id.au>
> Gesendet: 26.10.07 08:21:43
> An: "nhytro-python at web.de" <nhytro-python at web.de>
> CC: storm at lists.canonical.com
> Betreff: Re: [storm] Building large queries with Storm ORM


> 
> On 26/10/2007, nhytro-python at web.de <nhytro-python at web.de> wrote:
> > I have to code an extended search for a site, the search criteria can be built from large groups of values which are retrieved from checkboxes. I have 4 groups and each group has at least 10 checkboxes, each group result has to be joined with the next to acheive the final result.
> >
> > My question is, how can I build such a query using the Storm ORM to search tables? Some of the values in the checkboxes would be "None" so I cant have a definite number of substitution Strings, and joong all of them afterwards makes my head spin.
> >
> > Doe someone have a snippet for me on how I could acheive this?
> 
> You can build up queries using Storm's expression logic.  For
> instance, if I was building a query from a search form, I might do
> something like this:
> 
>     conditions = []
>     if field1_values:
>         conditions.append(In(Table.field1, field1_values))
>     if field2_values:
>         conditions.append(In(Table.field2, field2_values))
>     ...
>     results = store.find(Table, And(*conditions))
> 
> Is this the sort of thing you were wondering about?
> 
> James.
> 


_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066




More information about the storm mailing list