Re: Select Single Random Record

Pʀoмᴇтнᴇυs 0x01 <[email protected]>
Newsgroups gmane.comp.python.sqlobject
Message-ID <CANWRJHQ5Ja4s0UkR2dwam5C78KoNFRtBJd-a9hEkrDObXa4R=Q@mail.gmail.com>
I'll see about adding a recipe to the SQLObject Community Doc site for this.

(  https://sites.google.com/site/sqlobject/  )

On Wed, Apr 18, 2012 at 12:46 PM, Petr Jakeš <[email protected]> wrote:

>
> To give context to the issue, I am building my own icecast2 broadcaster. I
>> want
>> to have an Auto DJ feature which will pick a random song from the
>> database which
>> hasn't recently been played plus some other criteria. It really doesn't
>> matter
>> which record i get back from the database, I just need one at random.
>>
>
> *Get the list of valid IDs from the remote database using the raw SQL
> command
> something like:*
>
> con = connectionForURI("firebird://yourUserName:yourPassword@serverAddress
> :3050/pat/to/database/database.file")
>
> validIDs= "SELECT ID FROM SONGS_TABLE where ......"
>
> returnedIDs = con.queryAll(validIDs)
>
> # you get the list of valid IDs, something like this: [(1,), (2,), (3,),
> (4,), (5,), (6,), (7,), (8,), (9,), (11,)]
>
> *than:*
>
> import random
> randomID = random.choice(returnedIDs)[0]
> randomSong = SongsTable.get(randomID)
>
> HTH
>
> Regards
>
> Petr
>
>
> ------------------------------------------------------------------------------
> Better than sec? Nothing is better than sec when it comes to
> monitoring Big Data applications. Try Boundary one-second
> resolution app monitoring today. Free.
> http://p.sf.net/sfu/Boundary-dev2dev
> _______________________________________________
> sqlobject-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
>
>

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev

_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.