OT: making queues in DB

Brian Kelley bkelley at wi.mit.edu
Thu Apr 8 18:04:09 EDT 2004


Mitja wrote:
> I have a games page, on which I would like to display a list of 10 last
> downloaded games. Therefore, I'd need a kind of queue in the database. What
> is the best way to go about this? Extending each game's entry with a
> "timelastdownloaded"-like column is of course an option, but I don't favor
> it too much.

Why not?  This seems to be the most reasonable solution, then your sql 
statement to the database would be something like:

SELECT * from gametable
ORDER BY timelastdownloaded DESC
limit 10

The order by is a descending order from the current date to the last 
date, and the limit 10 gets the last 10.

If you are worried about performance you can modify the select to return 
only the games downloaded from the last month or so.  Or if the table 
gets too large, just delete the earliest entries.

Brian







More information about the Python-list mailing list