well... the thing is an AST of a very simple language - python-like expressions (and that is not SQL! e.g. a.b.c == x.y.z && whateverelse). u can do with that AST whatever u want - save/load or translate into something else, that is, another grammar. u can build a gui builder/editor over the tree... just like any other tree. start from dbcook/util/expr.py. see if u can handle (load/save/edit/...) that one. then, pick whatever u want from the dbcook/expression.py - that's a translator only - say u can omit the a.b.c.d joins, they don't 100% work anyway.
we did need such gui query-editor, and we had made some, but no time to make it abstract enough / tree-like, so only one level of either ORs or ANDs, and handling just few known object-types (like kmail's filters). this SA-gui-query-builder question comes over and over so many times, still i haven't seen a good _abstract_ usable & programmable one - one u feed the classes and their attributes. i think KDE (or was it openoffice) has a tree-visualizing regular-expresion builder, but it's hardcoded for REs, and i doubt it's in python. this can be a big effort; think well -- but can be rewarding... ah, warning: the possible combinations of tests for THIS is awfuly huge. There is test/other/expression.py, that tries to make 40something cases multiplied by say 10 different scenarios of inheritance / relationship... make your set of tests first - the spec - and stick to that only. ciao svil On Friday 03 April 2009 20:35:05 Christiaan Putter wrote: > Hi Svil, > > My integration between traits and sqlalchemy is working rather well > (at least it's passing the unit tests I could think of). Thanks > for all your help on that. > > Now I'm trying to do something similar to what you did in dbcook > with expressions. I'd like to construct a gui for the user to > build queries with, save those queries etc. > > I started off simply using the filter() and order_by() functions, > though those are attached to a particular session which isn't very > useful. The way you did it is much better obviously, so something > like > > results = session.query( klas).select( expr.walk( Translator( > context_Vars, context_classes > > is exactly what I need. Can the expression be saved and modified > again at a later stage? > > Though I don't know if I require all the functionality you have in > your expression modules. Or perhaps I do. > > Basically I'd just like the user to be able to select those columns > on the class that's being queried, and any other classes with > foreign key constraints. That's simple to setup, the trick will be > with all the different operators and parameter bindings. > > Is their a subset of things I should go through in your expression > module to understand what I need to do something similar with a > gui, or is everything very tightly integrated? > > Hope you're having a good weekend. > > Regards, > Christian > > 2009/4/1 <a...@svilendobrev.com>: > > i have similar thing, but by keeping an expression in my own > > terms and rendering into different things, like text, SQL, > > SA-expresion, etc. u define what is a variable, const, functor, > > overload all the operators, etc etc; then have a visitor that > > walks and translates (interprets) it into whatever one needs. > > > > see the generic one > > http://dbcook.svn.sourceforge.net/viewvc/dbcook/trunk/dbcook/utik > >/expr.py and the above-into-SA-translator (automaticaly doing > > other stuff) > > http://dbcook.svn.sourceforge.net/viewvc/dbcook/trunk/dbcook/expr > >ession.py > > > > ciao > > svil > > > > On Wednesday 01 April 2009 21:18:23 Hinrich Winther wrote: > >> Maybe there is a better way of doing it. To be exact: > >> > >> I want to disassemble a given _BinaryExpression into basic > >> elements (a list of strings, arrays, integers ...) and > >> reassemble it somewhere else out of this basic elements. > >> > >> On 01.04.2009, at 18:14, Michael Bayer wrote: > >> > Hinrich Winther wrote: > >> >> Hi, > >> >> > >> >> I need to generate a > >> >> sqlalchemy.sql.expression._BinaryExpression by hand. So I > >> >> looked into the docu and found that I need a left, right and > >> >> a operator. I am stuck at the left :) type() says it is a > >> >> sqlalchemy.sql.util.AnnotatedColumn. But I can't find the > >> >> class definition anywhere in sqlalchemy. Where is it defined? > >> > > >> > if you just say column('foo') == column('bar') (column is > >> > sqlalchemy.sql.column), you've got a _BinaryExpression. > >> > there shouldn't > >> > be a need to access _BinaryExpression directly. > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---