sql like functionality to query zcatalogs
Hi all, This one has been nagging me. Is there some way to search a zcatalogs indexes using SQL? I have a few thousand objects that have price scattered throughout a site I am building. I am looking the price up in a MySQL database based on the objects id. I am seeking a way of cataloging all the objects ( done ) and search that catalog for objects with prices between a certain range. For example: select * from zcatalog where price > 2.5 and price < 2.75 If not sql, which way would be the most simple to do this? Thanks in advance Joel Jensen.
Hi Joel
For example: select * from zcatalog where price > 2.5 and price < 2.75
result = Catalog(price = {'query': [2.5, 2.75], 'range': 'minmax'}) should do the job. price would have to be a FieldIndex. See http://zope.org/Documentation/Books/ZopeBook/2_6Edition/SearchingZCatalog.st x Andrew -- Logical Progression Ltd, 20 Forth Street, Edinburgh EH1 3LH, UK Tel: +44 (0)131 550 3733 Web: http://www.logicalprogression.net/
On Friday 16 April 2004 07:47 am, Joel Jensen wrote:
Hi all,
This one has been nagging me.
Is there some way to search a zcatalogs indexes using SQL?
I have a few thousand objects that have price scattered throughout a site I am building. I am looking the price up in a MySQL database based on the objects id.
I am seeking a way of cataloging all the objects ( done ) and search that catalog for objects with prices between a certain range.
For example: select * from zcatalog where price > 2.5 and price < 2.75
If not sql, which way would be the most simple to do this?
As the above post indicates, there's a lot you can do with standard zope queries. It is very helpful to learn the full syntax (see the Zope Book). There is also a product called CatalogQuery which you might find helpful. Its main advantages are '!='/'not in' operators, and 'or' searches (probably ZCatalog's biggest limitation). I doubt that it is still compatible with current zope versions, but it might not be too much trouble to get it working again: http://zope.org/Members/Kaivo/CatalogQuery/ Perhaps updating it would be a good way to familiarize yourself with some zope internals, if you are interested in doing so. Good Luck, Alec Mitchell
participants (3)
-
Alec Mitchell -
Andrew Veitch -
Joel Jensen