On Aug 23, 2008, at 12:10 PM, GustaV wrote:

>
> Hi all,
> Really, you do an amazing job on that stuff, it's a pleasure to work
> with!
>
> A short question though. It's possible to get a random order on
> selects in mysql using the RAND() in parameter of ORDER BY. I know
> similar (but different) was possible on others.
> What about sqlalchemy?
> The goal is to have only one result on the query, randomly.
>

if the function is RAND(), you'd just say  
select.order_by(func.rand()).    If you're looking for just the first  
result then you'd use limit/offset (the select() and Query()  
constructs both support limit() and offset() methods for this).

I'm not familiar with the "random function" of other databases but the  
same techniques apply.   SQLA could also could also support with a  
"generic" version of this function which calls the correct rand()  
function on each database, but only if very similar choices exist on  
most backends.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to