How do you know it's not random? If it's truely random, you will get repeats. I think you want something other than random.
In any case, if you use pagination, your results will be sorted. Check db._lastsql On Friday, November 21, 2014 7:32:00 AM UTC-7, Dominique wrote: > > Hello, > > I have a small personal website published on PythonAnywhere. > PythonAnywhere upgraded SQLITE some time ago. > Since then, one query doesn't work anymore. > > It is a query with a many to many relationship and the select should give > results at random. > rows = db(...).select(..., orderby='<random>') > It doesn't return me a random set of rows but rather always the same rows, > starting from the beginning of the possible matching rows. > > I tried to address the problem without success. > > I also tried not using the web2py dialect and replacing it with > > import random > rows=db(...).select().sort(lambda row: random.random()) > > > as explained in the web2py doc. No success either. > > I also replaced the query with explicit SQL statement using > db.executesql( SELECT.....ORDER BY RANDOM() ) > > No success ! > > I downloaded the database onto my home pc and tested with the same website > in local. > It works perfectly at home. > > I tested on PythonAnywhere another model (based on the docs > http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Many-to-many > ). > It works fine returning results randomly. So it seems the upgrade of > SQLite done by PythonAnywhere is not responsible for the problem. > > Does anybody have an idea what's going on, why the query doesn't work on > PythonAnywhere and works locally ? > > Thanks for any hint > Dominique > > -- 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.