On Mar 27, 2008, at 5:31 PM, maxi wrote:
> > Hi, > > Is possible (Are there some built-in function?) to convert a string > sql expresion to sqlalchemy expression? > > I will try to explain this with an example.... > > An user_table and User mapped class: > > sql_where = 'name like '%John%' > > sql_where -> User.name.like('John') > > sql = user_table.select() > sql.append_whereclause(sql_converted_expresion) > > Or.... > > param = ['name', 'like', '%John%'] > > and convert param list into sqlalchemy expression > > Is possible do anything like this? (I hope be clear) > hey there - no, thats not built in, it would require that you construct a SQL parser which generates a construct as it encounters tokens. Ned Batchelder did a great blog post on available parsers for Python: http://nedbatchelder.com/text/python-parsers.html . In particular is the "kwParsing" module, used by Gadfly: http://gadfly.sourceforge.net/ . Thats a SQL database written in Python so they are definitely parsing SQL in there. Their parsing approach could almost certainly be repurposed to output SQLA tokens (or any kind of tokens) with some degree of effort. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---