executesql doesn't allow more than one statement per invocation. You'll get the same issues running execute() with the underlying driver. What are you really trying to execute isn't a query: it's more of a stored procedure that returns a set of results.
On Tuesday, March 10, 2015 at 8:36:28 PM UTC+1, naveed wrote: > > I need to execute multiple lines of SQL in web2py, something like this: > > db.executesql("set @num := 0, @type := '';")\ > rows = db.executesql("select type, variety, price\ > from (\ > select type, variety, price,\ > @num := if(@type = type, @num + 1, 1) as row_number,\ > @type := type as dummy\ > from fruits\ > order by type, price\ > ) as x where x.row_number <= 2;") > > But, when I run it I don't get expected results in web2py (the variables > don't get initialized), even though it works from the mysql console. What > am I doing wrong? > > They don't work, even if I put the variable initialization in the same > call. This piece of SQL is from here: > http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/ > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.