tags:

views:

458

answers:

1

In my C++ programs, I'm used to the connection process prompting for a missing password or letting you select your own connection. Whe I use pyodbc.connect(), an exception is generated instead.

Traceback (most recent call last):
  File "<pyshell#41>", line 1, in <module>
    c=pyodbc.connect('')
Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnectW)')

The pyodbc documentation for Connection Strings states that pyodbc calls the C function SQLDriverConnect. The prompting behavior is controlled by the DriverCompletion parameter, and I can't see a way to set that parameter from Python.

+2  A: 

I'm not sure if you can, I just checked the source for this and it seems like it always sends SQL_DRIVER_NOPROMPT.

See line 88 in connection.cpp

KeeperOfTheSoul
Thank you for that link to the source, it was very informative. I wonder why they don't expose that parameter to Python?
Mark Ransom