Re: Help me with this query

2011-12-23 Thread Babatunde Akinyanmi
Thanks guys. The pyodbc option seems to be the best as i've discovered that QuerySet cannot also be random.shuffleD On Fri, Dec 23, 2011 at 11:09 PM, Python_Junkie < software.buy.des...@gmail.com> wrote: > You can use the full functionality of sql and python by executing sql > queries using the py

Re: Help me with this query

2011-12-23 Thread Python_Junkie
You can use the full functionality of sql and python by executing sql queries using the pyodbc module. The module is documented at this url http://code.google.com/p/pyodbc/ You can combine sql and python logic and not have to be constrained by the abstraction of raw sql or the ORM. in your django

Re: Help me with this query

2011-12-23 Thread Sebastian Goll
On Fri, 23 Dec 2011 20:16:11 +0100 Babatunde Akinyanmi wrote: > I actually have a database with thousands of records from which I have > to randomly select just 10 records from the thousands during every > query. Because of efficiency, I use the normal select with limit query > using a random num

Re: Help me with this query

2011-12-23 Thread Babatunde Akinyanmi
X_X I can't believe I didn't even think of that. Thanks maiyte On 12/23/11, Nan wrote: > Try Python's slicing syntax. [1] > > [1] > https://docs.djangoproject.com/en/dev/topics/db/queries/#limiting-querysets > > On Dec 23, 2:16 pm, Babatunde Akinyanmi wrote: >> Hello, >> How can I get the ORM to

Re: Help me with this query

2011-12-23 Thread Nan
Try Python's slicing syntax. [1] [1] https://docs.djangoproject.com/en/dev/topics/db/queries/#limiting-querysets On Dec 23, 2:16 pm, Babatunde Akinyanmi wrote: > Hello, > How can I get the ORM to do the equivalent of this sql query with the > result being a QuerySet: > > SELECT * FROM table LIMI

Help me with this query

2011-12-23 Thread Babatunde Akinyanmi
Hello, How can I get the ORM to do the equivalent of this sql query with the result being a QuerySet: SELECT * FROM table LIMIT expr. I know I can use objects.raw() but I need to shuffle the results and RawQuerySet objects do not have __len__() making it impossible to random.shuffle. I actually