Subject | Re: [firebird-python] How do i build the documentation ? |
---|---|
Author | Pavel Cisar |
Post date | 2011-11-11T16:10:20Z |
Dne 11.11.2011 16:56, mariuz napsal(a):
Dunno why not, as it's quite simple to implement, just add these next
methods:
def next(self):
row = self.fetchone()
if row:
return row
else:
raise StopIteration
def __iter__(self):
return self
best regards
Pavel Cisar
IBPhoenix
>Yes, firebirdsql's cursor object doesn't support the iterator protocol.
> Thanks i have started with the tutorial and testing the examples from it
>
>
>>>> con = firebirdsql.connect(dsn='localhost:/tmp/test.fdb', user='sysdba', password='masterkey')
>>>> SELECT = "select name, year_released from languages order by year_released"
>>>> cur.execute(SELECT)
>>>> cur = con.cursor()
>>>> cur.execute(SELECT)
>>>> for (name, year_released) in cur:
> ... print '%s has been publicly available since %d.' % (name, year_released)
> ...
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: 'Cursor' object is not iterable
Dunno why not, as it's quite simple to implement, just add these next
methods:
def next(self):
row = self.fetchone()
if row:
return row
else:
raise StopIteration
def __iter__(self):
return self
best regards
Pavel Cisar
IBPhoenix