我尝试从sqlserver
到postgres
进行自动迁移,所以我尝试使用pyodbc然后安装它
pip install pyodbc
在我尝试使用以下代码与python建立连接后:
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
当我尝试运行它时,我得到以下错误:
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
环境信息:
答案 0 :(得分:2)
你需要安装合适的odbc
表示mysql brew install mysql-connector-odbc
和postgres brew install psqlodbc