This is dangerous because vulnerable to SQL Injections. Anyway.... a query can be a valid SQL WHERE clause:
x = "table.id == %i" % value query = x set = db(query) row = set.select() in this case x is valid SQL. Notice it is not 'db.table.id' but 'table.id' because db is a web2py animal not a SQL animal. On Sep 10, 9:41 am, Don <sam...@gmail.com> wrote: > Okay, that was a bad example and my fault. Let's try again > > x = 'db.table.id == value' > query = x > set = db(query) > row = set.select() > > This will fail because the "query" variable is not a gluon.sql.Query > object, it is just a string. How can I convert from a string to a > query? > > On Sep 10, 10:32 am, Yarko Tymciurak <yark...@gmail.com> wrote: > > > the "idiom" is db(WHERE_CLAUSE).select(FROM_CLAUSE) (a simplification, but > > you get the idea) > > > so you want > > > query_results = db(x).select() > > > or (equivalently): > > > query_results = db(x).select(db.table.ALL) > > > On Thu, Sep 10, 2009 at 9:26 AM, Don <sam...@gmail.com> wrote: > > > > Ex: > > > x = 'db.table.id == value' > > > query = db(x) > > > > * This fails. Is it possible to convert a string into a query? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---