problem with SQL-DMO and win32com (and a workaround)

Geoff Talvola gtalvola at nameconnector.com
Thu Nov 1 18:07:15 EST 2001


SQL-DMO is a COM library that you use to administer MS SQL Server 
programmatically.  I was happily using the version of SQL-DMO that comes 
with SQL Server 7.0 with no problems.  Now that I upgraded to the SQL-DMO 
that comes with SQL Server 2000, I get the following error (using Python 
2.1 and win32all 139 or 140):

 >>> from win32com.client import gencache
 >>> s = gencache.EnsureDispatch('SQLDMO.SQLServer')
 >>> s.Connect('DBSERVER')
 >>> s.Databases('MyDatabase')
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
   File 
"win32com\gen_py\10010001-E260-11CF-AE68-00AA004A34D5x0x8x0\Databases.py", 
line 70, in __call__
     if ret is not None: ret = win32com.client.Dispatch(ret, '__call__', 
'{10020300-E260-11CF-AE68-00AA004A34D5}', UnicodeToString=0)
   File "win32com\client\__init__.py", line 95, in Dispatch
     return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, 
UnicodeToString, clsctx)
   File "win32com\client\__init__.py", line 35, in __WrapDispatch
     klass = gencache.GetClassForCLSID(resultCLSID)
   File "win32com\client\gencache.py", line 131, in GetClassForCLSID
     mod = GetModuleForCLSID(clsid)
   File "win32com\client\gencache.py", line 179, in GetModuleForCLSID
     __import__(sub_mod_name)
   File 
"win32com\gen_py\10010001-E260-11CF-AE68-00AA004A34D5x0x8x0\Database.py", 
line 48, in ?
     __import__('win32com.gen_py.10010001-E260-11CF-AE68-00AA004A34D5x0x8x0._Database2')
   File 
"win32com\gen_py\10010001-E260-11CF-AE68-00AA004A34D5x0x8x0\_Database2.py", 
line 23, in ?
     class _Database2(DispatchBaseClass):
NameError: name 'DispatchBaseClass' is not defined

If I instead use:

 >>> s = gencache.EnsureDispatch('SQLDMO.SQLServer', 0)

it works without errors.  So that's the workaround.  But it's slower and 
takes more memory.

If anyone (i.e. Mark Hammond :-)) would like to try to track this down, I 
can zip up and email the broken auto-generated files.  Just let me know.


--

- Geoff Talvola
   gtalvola at NameConnector.com




More information about the Python-list mailing list