Mark, yes, in part. What I cannot figure out -- and am not sure this
is possible with SQLAlchemy, is to go from strings, as returned from
HTTP Post's, representing the fields in the table (for the left side
of the relation) to the actual statemetn itself. In other words, if
the HTTP post calls for campring the "Lastname" column for equality to
the value smith, I can build the == 'smith' portfion, but how do I
Ibuild a String for the column name, into the value for that column
name so as to comport with SQLAlchemy's sytnax requirements. I don;t
think I can just have a query, q, and then say:
q = q.filter("lastname == 'smith'")
can I? RVince

On Aug 12, 10:33 am, Mark Erbaugh <m...@microenh.com> wrote:
> On Aug 12, 2011, at 10:21 AM, RVince wrote:
>
>
>
> > I'm trying to discern a means of creating a .filter(A rel B) where the
> > values for A, rel and B come from an parameters passed in to the web
> > page.
>
> > I already have an SQLAlchemy statement, say
> > query = Session.query(table).filter(A==B)
>
> > and I want to be able to allow for a "drilldown" of sorts by the, such
> > that from the web page they can pick a value from a dropdown, a
> > relation (from a dropdown) and a textbox to compare to. But my problem
> > is once I have these three values, how do I get them into
> > the .filter() function? That's not going to merely accept string
> > values -- is there a way to do this?
>
> > Thanks, RVince
>
> You can build your SQLAlchemy queries dynamically, i.e.
>
> q1 = query.Session.query(table).filter(A == B)
>
> q2 = q1.filter(C == D)
>
> q3 = q2.filter(E == F)
>
> you could apply different relationships using conditional Python statements:
>
> if rel == 'eq':
>         q4 = q3.filter(G == H)
> elif rel == 'neq':
>         q4 = q3.filter(G != H)
>
> is this what you're looking for?
>
> Mark

-- 
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.

Reply via email to