[storm] multiple join's
Gordon Allott
gordallott at gmail.com
Wed Jan 14 23:41:09 GMT 2009
On Wed, 2009-01-14 at 16:18 -0700, Alex Richardson wrote:
> On Wed, Jan 14, 2009 at 3:56 PM, Gordon Allott <gordallott at gmail.com> wrote:
> Gordon,
>
> There are two different topics that I think your posting touches on.
>
> First is the question of who to use a join in a query. The tutorial
> code you refer to properly demonstrates this. And it sounds like you
> don't have any trouble getting the table join to work.
>
> The second question is how to build a 'where' clause to select the
> appropriate rows. In the simple example above, you could use the
> following code to find the companies for Ben, Steve, and Jon:
>
> origin = [Company, Join(Employee, Employee.company_id == Company.id)]
> result = store.using(*origin).find(Company,
> (Employee.name.like(u"Ben%") | (Employee.name.like(u"Ben%") |
> (Employee.name.like(u"Ben%") ) )
>
> Note that the pipe operator '|' is shorthand for the more
> verbose/explicit use of the 'Or' method.
>
> result = store.using(*origin).find(Company,
> Or(Employee.name.like(u"Ben%"), (Employee.name.like(u"Ben%"),
> (Employee.name.like(u"Ben%") ) )
>
> The use of 'and', 'or' and 'in', to build more complex where clauses
> is touched upon in the storm manual.
> (https://storm.canonical.com/Manual)
>
> Alex Richardson
yes, but this method seems not to work, At the moment I am building up a
list that looks similar to: (like is not actually needed in my
situation)
employees = [Employee.name == u'Ben', Employee.name == u'Steeve',
Employee.name == u'John']
neither of the following work:
store.using(*origin).find(Company, *employees)
store.using(*origin).find(Company, And(employees))
although the following does:
store.using(*origin).find(Company, Employee.name == u'Ben')
# u'Steeve' and u'John' would work on their own also.
--
Gordon Allott (gordallott at gmail.com)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/storm/attachments/20090114/28b83733/attachment.pgp
More information about the storm
mailing list