[storm] Building large queries with Storm ORM
James Henstridge
james at jamesh.id.au
Fri Oct 26 09:59:29 BST 2007
On 26/10/2007, nhytro-python at web.de <nhytro-python at web.de> wrote:
> 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 In() object represents the SQL "IN" operator. So In(Table.field,
[1,2,3]) is an expression that checks to see if that field is one of
1, 2 or 3.
An equivalent of the above expression is:
Or(Table.field == 1,
Table.field == 2,
Table.field == 3)
> The * is a wildcard I presume, in this case its the the SQL equivalent, is it?
The * is standard Python syntax for converting a list into multiple
arguments to a function. The expression And(condition1, condition2,
condition3) is equivalent to "condition1 AND condition2 AND
condition3" in SQL.
So the code in my previous example constructed a list of conditions
then combined then with the AND operator. Does that make sense?
> 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?
This is an area where the Storm documentation is a bit lacking
(although there is a lot of simple examples of its use in the
tutorial). That said, it is quite a simple system if you have a basic
understanding of SQL.
If you have particular questions, please ask them.
James.
More information about the storm
mailing list