Michael,

Thanks for the quick reply.

Michael Bayer wrote:
> On Jan 11, 2009, at 4:51 PM, Werner F. Bruhin wrote:
>
>   
>> I can not find the answer looking through the 0.5 doc for my problem.
>>
>> query =  
>> session.query(db.SomeClass).filter(something).order_by(anorder)
>>
>> # get the first row
>> row = query.first()
>>
>> # display a dialog to the user
>> # one of the possible actions is to press a button which should show  
>> the
>> next row in the query
>> row = query.???()
>>
>> How could I use "fetchone()" on this?  Or is there another/correcter  
>> way
>> to do this type of thing ins SA?
>>     
>
>
> the query itself is an iterator, so you could say result =  
> iter(query); row = result.next() .
>
> now, if you are looking for the results from the *server* to be non- 
> buffered, that requires something more (namely yield_per()), but it  
> has a lot of caveats so I would not use it unless you absolutely know  
> what you're doing.
>   
Just for the archive, I ended up doing something along these lines:

    if self.searchInit:
            .... whatever is needed to setup the searchQuery
            self.searchResult = iter(self.searchQuery)
            try:
                row = self.searchResult.next()
            except StopIteration:
                ... do whatever if nothing is found
    else:
            try:
                row = self.searchResult.next()
            except StopIteration:
                .... do whatever when there are no more rows

Michael, thanks again for excellent support.
Werner

> >
>
>
>   


--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to