Gustavo Narea wrote: > Randy said: > > Does anyone know of a Python package that would provide query building > > functionality like Trac has when doing a custom query on the tickets? > > Are you talking about a front-end that allows end-users "assemble" the > query, or a back-end that turns user-provided data into a result filter > (e.g., SQL `WHERE` clause)? > > If it's the later, you may want to see this: > https://launchpad.net/booleano > Unfortunately it's a rather new piece of software and should get the first > alpha/usable release this week.
Heck, if all you want is the back end, Geniusql (and therefore Dejavu) allows you to build comparison expressions and combine them with "+", "&", and "|": >>> from geniusql import logic >>> a = logic.comparison('Name', 6, ['Dave', 'Jerry', 'Sue']) >>> a logic.Expression(lambda x: x.Name in ['Dave', 'Jerry', 'Sue']) >>> b = logic.comparison('Size', 2, 30) >>> b logic.Expression(lambda x: x.Size == 30) >>> a + b logic.Expression(lambda x: (x.Name in ['Dave', 'Jerry', 'Sue']) and (x.Size == 30)) >>> a & b logic.Expression(lambda x: (x.Name in ['Dave', 'Jerry', 'Sue']) and (x.Size == 30)) >>> a | b logic.Expression(lambda x: (x.Name in ['Dave', 'Jerry', 'Sue']) or (x.Size == 30)) >>> c = logic.Expression(lambda g, h: g.Name == h.Name) >>> c logic.Expression(lambda g, h: g.Name == h.Name) >>> a + c logic.Expression(lambda x, h: (x.Name in ['Dave', 'Jerry', 'Sue']) and (x.Name == h.Name)) You then pass those to the storage layer where they are automatically converted to backend-specific SQL etc. Been runnin' like a champ for years, not days. [1] Robert Brewer fuman...@aminus.org [1] OK, I did have to commit a patch just now for comparison() in py2.5+--but it's a short one ;) http://www.aminus.net/geniusql/changeset/280
_______________________________________________ Web-SIG mailing list Web-SIG@python.org Web SIG: http://www.python.org/sigs/web-sig Unsubscribe: http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com