Class _FlushableIterator
source code
object --+
|
_FlushableIterator
Cursor based iterator that may flush the cursor whenever needed.
Transactions to the database cannot be commited while a cursor is
being used. So it is unsafe for _SqliteBackend to return cursors direcly
because it may hinder further execution of methods using
transactions.
On the other hand, it may be inefficient to flush all cursors into
lists before returning them. This class provides an efficient
solution.
All cursors (or cursor based iterators) are wrapped info a
_FlushableIterator before being returned, and the latter is weakly
referenced by the backend instance. Whenever a transaction is started,
all known _FlushableIterators are flushed, i.e. they internally change
their underlying iterator into a list, so that the transaction can be
committed, but users can continue to transparently use them.
Note that this implementation uses the iterable interface of sqlite
cursors rather than the DB-API cursor interface. This is less portable,
but allows to wrap iterators that are not cursors but relying on a
cursor, e.g.::
return _FlusableIterator(( r[1] for r in conn.execute(query) ), be)
|
__init__(self,
cursor,
backend)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
source code
|
|
|
|
|
|
|
|
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__str__
|
|
_cursor
|
Inherited from object :
__class__
|
__init__(self,
cursor,
backend)
(Constructor)
| source code
|
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature
- Overrides:
object.__init__
- (inherited documentation)
|