[Twisted-Python] Is there twisted.enterprise.adbapi support for .executemany()?
Does anyone know of any (possibly experimental) twisted.enterprise.adbapi support for .executemany() ? (see http://www.python.org/dev/peps/pep-0249/ -- search for ".executemany") If not, I'll see if I can't add a runOperationMany() to twisted.enterprise.adbapi.ConnectionPool. The functionality I want is simple in theory. .executemany runs many identical insert/update/delete operations using a different dictionary in a supplied list of dictionaries for the input each time, and returns None on success of all of the queries, or rolls-back the whole transaction and returns a failure on an error. Passing it in any query that returns results would also result in returning a failure. ~ Nathan
On Apr 15, 2008, at 2:55 PM, Nathan wrote:
Does anyone know of any (possibly experimental) twisted.enterprise.adbapi support for .executemany() ?
(see http://www.python.org/dev/peps/pep-0249/ -- search for ".executemany")
If not, I'll see if I can't add a runOperationMany() to twisted.enterprise.adbapi.ConnectionPool. The functionality I want is simple in theory.
It definitely wouldn't be hard to create this function. You could add it to ConnectionPool, but a subclass would work equally well. Just take a look at how runOperation works, and create a similar function, runOperationMany(trans, *args, **kwargs). This should call runInteraction and pass your second function _runOperationMany(trans, *args, **kwargs) which uses the `trans` as the cursor object. Transaction instances like that automatically inherit all the attributes of the base cursor class in your particular driver, so you should be able to call executemany() without a problem. Hope that helps, -phil
participants (2)
-
Nathan
-
Phil Christensen