[Twisted-Python] ADBAPI and individual rows

Greetings! Digging a bit more into the DB side, and I wonder a bit about the API for adbapi. From what I can tell, the runQuery() will return a Deferred for the whole result set (which implies the result set is in memory). Is there a method or style for running a query in which each row will be passed back through a Deferred one at a time? (Basically, each cycle through reactor.run() would be returning a single row). What I am looking for is how to deal with a large result set without requiring the whole set be in memory. Should I be looking elsewhere within Twisted to do this? Regards! Ed

Il sab, 2003-08-09 alle 05:12, Justin Ryan ha scritto:
adbapi could almost definitely be extended to have a special method or paramater/flag to the existing methods for doing this.
a long time ago i promised to rework the adbpi (mainly to implement the min/max stuff that currently does not work). i'll start sending patches after the ccc (nobody twisted here?). the special method you talk of should be quite easy to implement. ciao, -- Federico Di Gregorio Debian GNU/Linux Developer fog@debian.org INIT.D Developer fog@initd.org God is real. Unless declared integer. -- Anonymous FORTRAN programmer

On Fri, Aug 08, 2003 at 07:12:00PM -0400, Edmund Dengler wrote:
Here's what I did with Ldaptor (note how the callback and the returned Deferred play together): def search(self, filterText=None, filterObject=None, attributes=(), scope=pureldap.LDAP_SCOPE_wholeSubtree, derefAliases=pureldap.LDAP_DEREF_neverDerefAliases, sizeLimit=0, timeLimit=0, typesOnly=0, callback=None): """ Perform an LDAP search with this object as the base. @param filterText: LDAP search filter as a string. @param filterObject: LDAP search filter as LDAPFilter. Note if both filterText and filterObject are given, they are combined with AND. If neither is given, the search is made with a filter that matches everything. @param attributes: List of attributes to retrieve for the result objects. An empty list and means all. @param scope: Whether to recurse into subtrees. @param derefAliases: Whether to deref LDAP aliases. TODO write better documentation. @param sizeLimit: At most how many entries to return. 0 means unlimited. @param timeLimit: At most how long to use for processing the search request. 0 means unlimited. @param typesOnly: Whether to return attribute types only, or also values. @param callback: Callback function to call for each resulting LDAPEntry. None means gather the results into a list and give that to the Deferred returned from here. @return: A Deferred that will complete when the search is done. The Deferred gives None if callback was given and a list of the search results if callback is not given or is None. """ -- :(){ :|:&};:

On Fri, 2003-08-08 at 16:12, Edmund Dengler wrote:
You should look at runInteraction. That calls a user-specified function with what is essentially a DB-API cursor in a separate thread. You can do what you like with the cursor, including fetching results one row at a time. You might also look at the Flow module. I've never used it, but I think it was designed to solve such problems. dave

Il sab, 2003-08-09 alle 05:12, Justin Ryan ha scritto:
adbapi could almost definitely be extended to have a special method or paramater/flag to the existing methods for doing this.
a long time ago i promised to rework the adbpi (mainly to implement the min/max stuff that currently does not work). i'll start sending patches after the ccc (nobody twisted here?). the special method you talk of should be quite easy to implement. ciao, -- Federico Di Gregorio Debian GNU/Linux Developer fog@debian.org INIT.D Developer fog@initd.org God is real. Unless declared integer. -- Anonymous FORTRAN programmer

On Fri, Aug 08, 2003 at 07:12:00PM -0400, Edmund Dengler wrote:
Here's what I did with Ldaptor (note how the callback and the returned Deferred play together): def search(self, filterText=None, filterObject=None, attributes=(), scope=pureldap.LDAP_SCOPE_wholeSubtree, derefAliases=pureldap.LDAP_DEREF_neverDerefAliases, sizeLimit=0, timeLimit=0, typesOnly=0, callback=None): """ Perform an LDAP search with this object as the base. @param filterText: LDAP search filter as a string. @param filterObject: LDAP search filter as LDAPFilter. Note if both filterText and filterObject are given, they are combined with AND. If neither is given, the search is made with a filter that matches everything. @param attributes: List of attributes to retrieve for the result objects. An empty list and means all. @param scope: Whether to recurse into subtrees. @param derefAliases: Whether to deref LDAP aliases. TODO write better documentation. @param sizeLimit: At most how many entries to return. 0 means unlimited. @param timeLimit: At most how long to use for processing the search request. 0 means unlimited. @param typesOnly: Whether to return attribute types only, or also values. @param callback: Callback function to call for each resulting LDAPEntry. None means gather the results into a list and give that to the Deferred returned from here. @return: A Deferred that will complete when the search is done. The Deferred gives None if callback was given and a list of the search results if callback is not given or is None. """ -- :(){ :|:&};:

On Fri, 2003-08-08 at 16:12, Edmund Dengler wrote:
You should look at runInteraction. That calls a user-specified function with what is essentially a DB-API cursor in a separate thread. You can do what you like with the cursor, including fetching results one row at a time. You might also look at the Flow module. I've never used it, but I think it was designed to solve such problems. dave
participants (5)
-
Dave Peticolas
-
Edmund Dengler
-
Federico Di Gregorio
-
Justin Ryan
-
Tommi Virtanen