1

I'm trying to do a automate migration from sqlserver to postgres, so I tryed to use pyodbc then installed it

pip install pyodbc 

And after I try to do a connection with python with below code:

import pyodbc

cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=192.168.0.12;DATABASE=Aval;UID=sa;PWD=1032')
cursor = cnxn.cursor()
cursor.execute("select * from user")
rows = cursor.fetchall()
for row in rows:
    print row.user_id, row.user_name

The when I atempt to run it I get the following mistake:

Traceback (most recent call last):
  File "migracion.py", line 1, in <module>
    import pyodbc
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/pyodbc.so, 2): Library not loaded: /usr/local/lib/libodbc.2.dylib
  Referenced from: /usr/local/lib/python2.7/site-packages/pyodbc.so
  Reason: image not found

Environment Information:

  • SO: Mac yosemite
  • python version: 2.7.10
  • pip version: pip 7.1.0 from /usr/local/lib/python2.7/site-packages (python 2.7)
Cristian
  • 1,480
  • 5
  • 32
  • 65
  • http://stackoverflow.com/questions/31981376/i-uninstalled-matplotlib-tried-to-reinstall-it-and-it-failed-to-be-imported-o/31981566#31981566 – dsgdfg Aug 14 '15 at 05:37

1 Answers1

2

U need to install proper odbc

for mysql brew install mysql-connector-odbc and for postgres brew install psqlodbc

pendolf
  • 308
  • 3
  • 10