The "Working with Large Collections" section in the advanced mapping docs is
probably what you want:
http://www.sqlalchemy.org/docs/adv_datamapping.myt#advdatamapping_properties_working

On 2/13/07, Cristiano Paris <[EMAIL PROTECTED]> wrote:
>
>
> I everyone. I'm pretty new to SQLAlchemy and never done much sql-related
> work in the past as well so this could possibly be a silly question.
>
> Suppose I've a table with a huge number of records. Now, I'd like to
> access this table randomly through a list-like interface of a Python
> class instance, i.e. saying foo[90] would return the 90th row of the
> table.
>
> I know how to accomplish this in play MySQL's SQL, maybe using a LIMIT
> clause in the select. This way it'd be trivial to write a container
> class implementing the __getitem__() method with a a SELECT/LIMIT
> statement.
>
> In addition, suppose that the SELECT statement contains a WHERE clause
> defined at foo instance's creation time (possibly through its
> constructor). Again, I'd simply plug the WHERE clause in the SELECT
> statement on every __getitem()__ invocation.
>
> I think it's be possible to implement such a beast through SQLAlchemy's
> API and I thought that Query's select() method of a mapper worked that
> way, but it seems that it fetches every and each row from the DB just
> before returning a list of the mapped object instances.
>
> Am I wrong? Is there a way/class in the SA's API to have sort of a lazy
> list of results of a query from which to pick randomly?
>
> Thank you,
>
> Cristiano
>
> >
>

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