Menu

#16 client.fetch*() not implemented

closed-fixed
None
5
2005-05-18
2002-08-23
No

gadfly.client.fetchone() and gadfly.client.fetchmany()
are not currently implemented. Here is a patch
implementing these functions and slightly modifying
fetchall() to use fetchmany(). This code is based on
the code in database.py.

diff -r1.1 client.py
98c98,117
< # should add fetchone fetchmany
---
> def fetchone(self):
> r = self.results
> if r is None:
> return None
> if len(r)<1:
> raise ValueError, "no more results"
> result = r[0]
> del r[0]
> return result
>
> def fetchmany(self, size=None):
> r = self.results
> if r is None:
> return None
> if size is None:
> size = len(r)
> result = r[:size]
> del r[:size]
> return result
>
100c119
< return self.results
---
> return self.fetchmany()

Discussion

  • Stuart Bishop

    Stuart Bishop - 2003-02-11
    • assigned_to: nobody --> zenzen
    • status: open --> open-postponed
     
  • Stuart Bishop

    Stuart Bishop - 2003-02-11

    Logged In: YES
    user_id=46639

    Hmm... I think at least fetchmany and fetchall should return
    an empty list if there are no results to be compatible with
    the DB API 2.0.

     
  • Stuart Bishop

    Stuart Bishop - 2005-05-18

    Logged In: YES
    user_id=46639

    Implemented in dbapi20.py by moellenb

     
  • Stuart Bishop

    Stuart Bishop - 2005-05-18
    • status: open-postponed --> closed-fixed
     

Log in to post a comment.