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

Alex Willmer alex at moreati.org.uk
Thu Jan 29 21:15:52 CET 2009

(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

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?

With thanks, Alex

Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import adodbapi
>>> conn = adodbapi.connect('Provider=SQLOLEDB.1;Data
Source=.\\SQLEXPRESS;Initial Catalog=MYDATABBASE;Integrated
Security=SSPI;User Instance=False;')
>>> curs = conn.cursor()
>>> curs.execute('select * from localview_roles')
>>> curs.execute('select * from localview_roles')

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python25\Lib\site-packages\adodbapi\adodbapi.py", line 713,
in execut
  File "C:\Python25\Lib\site-packages\adodbapi\adodbapi.py", line 664,
in _execu
  File "C:\Python25\Lib\site-packages\adodbapi\adodbapi.py", line 474,
in _raise
  File "C:\Python25\Lib\site-packages\adodbapi\adodbapi.py", line 60,
in standar
    raise errorclass(errorvalue)
Traceback (most recent call last):
   File "C:\Python25\Lib\site-packages\adodbapi\adodbapi.py", line
650, in _exec
   File "<COMObject ADODB.Command>", line 3, in Execute
   File "C:\Python25\lib\site-packages\win32com\client\dynamic.py",
line 258, in
    result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags,
retType, argTypes
) + args)
 com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft OLE
DB Provider
 for SQL Server', u'Cannot create new connection because in manual or
d transaction mode.', None, 0, -2147467259), None)
-- on command: "select * from localview_roles"
-- with parameters: None
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/db-sig/attachments/20090129/6d7b5fa2/attachment.htm>

More information about the DB-SIG mailing list