How to force use of unixodbc?

633 views
Skip to first unread message

Isaac

unread,
Dec 21, 2011, 2:00:36 PM12/21/11
to pyodbc
I'm getting the following error when trying to use pyodbc.connect

pyodbc.Error: ('IM002', '[IM002] [iODBC][Driver Manager]Data source
name not found and no default driver specified. Driver could not be
loaded (0) (SQLDriverConnectW)')

I am able to connect using tsql and isql. When I run:

isql --version
unixODBC 2.3.0

I think (but feel free to disabuse me), that my problem would be
solved if pyodbc were using unixODBC. What is recommended way of doing
this? I've scratched my head over setup.py quite a bit, but I can't
discern what I might change there to get what I want on a rebuild.

I'm on OSX 10.7
Python 2.7.2 |EPD 7.1-2 (64-bit)| (default, Jul 27 2011, 14:50:45)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin

and FreeTDS version 0.91

Thanks,
-Isaac

Michael Kleehammer

unread,
Dec 26, 2011, 7:55:01 PM12/26/11
to pyo...@googlegroups.com
First, are you sure that's what you want to do?  iODBC is what ships on OS/X.

The Linux builds use "odbc" as the library name instead of "iodbc".  I would assume it has the same name on OS/X.

        settings['libraries'].append('odbc')

Good luck.

bpanulla

unread,
Dec 30, 2011, 2:51:02 PM12/30/11
to pyodbc
On Dec 21, 11:00 am, Isaac <isaac.laugh...@gmail.com> wrote:
> I'm getting the following error when trying to use pyodbc.connect
>
> pyodbc.Error: ('IM002', '[IM002] [iODBC][Driver Manager]Data source
> name not found and no default driver specified. Driver could not be
> loaded (0) (SQLDriverConnectW)')

Did you install unixODBC with MacPorts? I had exactly the same problem
on 10.7 connecting to PostgreSQL and MySQL. I just submitted a patch
to MacPorts[1] that solves it for me.

The trick appears to be adding the MacPorts include/library paths
under /opt/local to setup.py:

settings['include_dirs'] = ['/opt/local/include']
settings['library_dirs'] = ['/opt/local/lib']

I got the hint from this Stack Overflow discussion[2].

Hope this helps!

-B

[1] https://trac.macports.org/ticket/32706
[2] http://stackoverflow.com/questions/7881985/using-alternate-unixodbc-installation

bpanulla

unread,
Dec 30, 2011, 2:56:28 PM12/30/11
to pyodbc


On Dec 26, 4:55 pm, Michael Kleehammer <mkleeham...@gmail.com> wrote:
> First, are you sure that's what you want to do?  iODBC is what ships on
> OS/X.

It may ship with it, but I'm not sure it actually *works* with common
drivers, especially across 32-bit/64-bit and PPC/Intel architecture
gaps. The only stable, reliable solution I've been able to find as
been to use unixODBC installed via MacPorts.

-B

pacopablo

unread,
Dec 30, 2011, 3:56:19 PM12/30/11
to pyodbc
Works just fine. I have been using iODBC with pyodbc and the FreeTDS
driver without any problems in OSX 10.5 through 10.7

-John

bpanulla

unread,
Jan 4, 2012, 2:38:46 PM1/4/12
to pyodbc
Fair enough... I can really only speak for 10.6. I haven't tried on
10.7 yet
since my unixODBC kit is working fine since my transition.

Maybe the FreeDTS project team has more Mac expertise. Did
you install from source? There could be some wisdom in the build
process
that I could filter back to the psqlODBC team.

-B
Reply all
Reply to author
Forward
0 new messages