[DB-SIG] Reuse of DB-API 2.0 cursors for multiple queries?

M.-A. Lemburg mal at egenix.com
Thu Jan 29 22:07:14 CET 2009


On 2009-01-29 22:05, Andy Todd wrote:
> M.-A. Lemburg wrote:
>> On 2009-01-29 21:15, Alex Willmer wrote:
>>> (Reposted to DB-SIG from clp)
>>>
>>> This week, I used the adodbapi module against an SQL Server Express
>>> database. I was surprised to get an exception, when I attempted to
>>> submit a second query with my cursor object. The full session is
>>> below.
>>>
>>> With cx_Oracle I've become used to reusing a cursor for subsequent
>>> queries. The PEP doesn't specify either way, that I can see. Is this
>>> behaviour left to the implementation, or should I be able to expect a
>>> cursor is reusable?
>>
>> This should be possible. In fact the statement caching mechanism outlined
>> in the DB-API spec relies on this: if you pass in the same query twice,
>> the module can opt to reuse the already prepared statement.
>>
> 
> In that case shouldn't the DB-API be amended to say this? After all
> "explicit is better than implicit".

Yes, I'll add a note.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jan 29 2009)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/


More information about the DB-SIG mailing list