Reuse of DB-API 2.0 cursors for multiple queries?

Carsten Haese carsten.haese at
Thu Jan 29 01:47:02 CET 2009

moreati wrote:
> Today, 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.

The PEP doesn't say explicitly that a cursor can execute multiple
queries, but it's definitely implied by the second paragraph:


            Prepare and execute a database operation (query or
            command).  Parameters may be provided as sequence or
            mapping and will be bound to variables in the operation.
            Variables are specified in a database-specific notation
            (see the module's paramstyle attribute for details). [5]

            A reference to the operation will be retained by the
            cursor.  If the same operation object is passed in again,
            then the cursor can optimize its behavior.  This is most
            effective for algorithms where the same operation is used,
            but different parameters are bound to it (many times).

You might want to check on a list dedicated to adodbapi whether there
are module-specific quirks or caveats to watch out for. Or wait for
somebody with adodbapi-specific knowledge to chime in.


Carsten Haese

More information about the Python-list mailing list