[Zope] Understand ZODB Query?

J Cameron Cooper jccooper@jcameroncooper.com
Tue, 11 Mar 2003 13:34:57 -0600


>
> - I can easily perform SQL statement to lookup for some information 
> such as, total employee, who are above 30 years old, and who has the 
> Lastname of 'Smith'.
> - I can easily retrieve information from multiple tables and combine 
> it as data objects.
>  
> But how can I do this in ZODB?

1) If your data set is not too big, you can do it programmatically Python:

set = folder.objectValues()
results = []
for elt in set:
  if (elt.age > 30) and (elt.lastname=='Smith'):
    results.append(elt)
return elt

One can easily replace '30' and 'Smith' with parameters to get a more 
useful script.

2) Use ZCatalog for this if you have larger sets to avoid unnecessary 
traversals.



But I suspect the larger problem is that you're thinking tabularly. 
Trying to make a 1-to-1 translation between an object-storage scheme and 
a relational-storage scheme isn't always (or maybe usually) going to 
work. I know no magic processes for this, unfortunately.

       --jcc