When I run the following two lines which should work on any system with SQL Server installed I get an error:
C:\r>python
ActivePython 2.4.2 Build 10 (ActiveState Corp.) based on
Python 2.4.2 (#67, Jan 17 2006, 15:36:03) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from adodbapi import connect
>>> cnn = connect('Provider=SQLOLEDB.1;Data Source=(local);Initial Catalog=master;Integrated Security=SSPI')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\app\python\lib\site-packages\adodbapi\adodbapi.py", line 264, in connect
return Connection(conn)
File "C:\app\python\lib\site-packages\adodbapi\adodbapi.py", line 311, in __init__
for indx in range(adoConn.Properties.Count):
File "c:\app\python\lib\site-packages\win32com\client\__init__.py", line 455, in __getattr__
return self._ApplyTypes_(*args)
File "c:\app\python\lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_
return self._get_good_object_(
pywintypes.com_error: (-2147352573, 'Member not found.', None, None)
The error is in the following code in adodbapi.py:
class Connection:
def __init__(self,adoConn):
self.adoConn=adoConn
self.supportsTransactions=False
for indx in range(adoConn.Properties.Count):
if adoConn.Properties(indx).Name == 'Transaction DDL' \
and adoConn.Properties(indx).Value != 0: #v2.1 Albrecht
self.supportsTransactions=True
self.adoConn.CursorLocation = defaultCursorLocation #v2.1 Rose
if self.supportsTransactions:
self.adoConn.IsolationLevel=defaultIsolationLevel
self.adoConn.BeginTrans() #Disables autocommit
self.errorhandler=None
self.messages=[]
global verbose
if verbose:
print 'adodbapi New connection at %X' % id(self)
Apparently adoConn.Properties.Count throws an exception!!! This is easily fixed by replacing this code:
for indx in range(adoConn.Properties.Count):
if adoConn.Properties(indx).Name == 'Transaction DDL' \
and adoConn.Properties(indx).Value != 0: #v2.1 Albrecht
self.supportsTransactions=True
With the more readable:
for property in adoConn.Properties:
if property.Name == 'Transaction DDL' \
and property.Value != 0: #v2.1 Albrecht
self.supportsTransactions=True
This bugfix / patch / enhancement request has been addressed in a subsequent release.
Thanks!
Fix is in 2.3.0
Was it fixed just for Sql Server ? Because I had the same problem with adodbapi v2.6.0.7 and this post made my day !