I'm trying to use pyodbc to connect to a SQL Server (MS SQL Server through FreeTDS) in a portable application; since it's supposed to be standalone, I would like to avoid having to explicitly install the driver on the system, just bringing the ODBC driver dll along the application.
This page suggests that it's possible to specify the driver dll directly in the connection string
Specify the
DRIVER=
parameter in theszConnStrIn
argument to theSQLDriverConnect
function. For example:szConnStrIn = "driver=ospath/dbodbc6.dll;dbf=c:\asademo.db"
where
ospath
is the operating system subdirectory of your Adaptive Server Anywhere installation directory.
Trying it through pyodbc+libtdsodbc.so
on Linux, it does work fine; however, trying the same on Windows (pyodbc+tdsodbc.dll
) I always get
pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
(my libtdsodbc.so
seems to be fine, though, since, if I install it as a "regular" driver and refer it with its name it connects fine)
Checking the documentation of SQLDriverConnect
and related pages there's no mention of the DRIVER=
option used straight with the dll path.
So, isn't "straight-to-driver-dll" connection not supported on Windows? Are there any alternatives, especially with Python, to connect straight to the driver dll, bypassing the ODBC driver manager?