Error importing adodbapi: "No such key..."

324 views Asked by At

I would dearly love to use the adodbapi module, but I can't get it to import. The latest version for Python 3.2 32 bits appears to have a syntax error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.4\helpers\pydev\pydevd.py", line 2358, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.4\helpers\pydev\pydevd.py", line 1778, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.4\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc) 
  File "C:/Customers/Calvert/Scripts/test_adodb.py", line 1, in <module>
    import adodbapi
  File "C:\Python32\lib\site-packages\adodbapi\__init__.py", line 16, in <module>
    from .apibase import apilevel, threadsafety, paramstyle
  File "C:\Python32\lib\site-packages\adodbapi\apibase.py", line 495
    raise er,'No such key as "%s" in %s'%(repr(key),self.__repr__()),tr

What do I have to do to get around this? Is this Python 2 syntax in a file designed for Python 3? The name of the file I downloaded from SourceForge is pywin32-220.win32-py3.2.exe, and it was dated 1/11/16.

2

There are 2 answers

2
ROBERT RICHARDSON On BEST ANSWER

Apparently, I was correct. This module, labeled for python 3.2, contains Python 2 code. I ran 2to3 on it, and the syntax error went away.

0
QA Collective On

It appears that the adodbapi codebase on both SourceForge (https://adodbapi.sourceforge.net/) and PyPy (https://pypi.org/project/adodbapi/2.4.2.1/) is either old and/or unmaintained. It appears to live on through pywin32.

So upon encountering this error, in stead of the answer above, I simply installed pywin32 in place of adodbapi and my code worked fine:

pip uninstall adodbapi
pip install pywin32