i can offer you my sa_expr wrapper, which converts pure python funcs 
into SA where clauses. It works for most cases, figuring out joins 
etc. Of course it cannot do the full complexity of SA, what to say 
about the plain SQL.

whether it will be appropriate or not for your task, is up to you.

it's in a bit of messy state right now, but will get cleaned soon. See 
the long list of test cases towards the bottom to see what it can and 
what cannot do. The tests are not exhaustive enough nor covering all 
possible setups/situations (some of them can be changed by external 
switches), but will give u idea of target functionality.

for plain usage u need only sa_expr.py and sa_util/expr.py - none of 
the other stuff, although it will be needed for testing.

http://linuxteam.sistechnology.com/o2rm/sawrap0420.tar.bz2


ciao
svilen

On Thursday 19 April 2007 19:37:20 vkuznet wrote:
> Hi,
> I'm developing a web application where users are allowed to specify
> where statement. So I can capture it as a string, e.g.
> ( T1.C1=1 OR T1.C1=5) AND T3.C3 like 'test%'
>
> where T1 is table 1 and C1 is column 1, and so on. Now the hard
> question is how to add such string to sqlalchemy query? I've look
> at a code and one possible way I see is to created a TextClause
> with binded parameters. But even if I can, the hard part would be
> to preserve brackets and AND/OR between different conditions. So,
> it should be a way to substitue Table.Column with sqlalchemy.Column
> (which I can do), and rvalues with binded names, and create a dict
> of binded parameters, and just pass a string like
>
> ( T1.C1 = :param1 OR T1.C1 = :param2 ) AND T3.C3 like :param3
> {'param1':1, 'param2':5,'param3':'test%'}
>
> to given query
>
> Is there any way to address this issue. I'll be glad if someone
> will give me some guidelines.
>
> Thanks,
> Valentin.
>
>
> 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to