我正在尝试使用 pyodbc 连接到数据库,以下代码在 Windows 上运行良好,尝试在 linux 上运行相同的代码会出现如下错误,任何人都可以建议这里有什么问题以及如何解决它?
import pypyodbc as pyodbc
component_id=argv[1]
print "COMPONENT ID: " + component_id
server_name='odsdb.company.com'
database_name='ODS'
cnx = pyodbc.connect("DRIVER={SQL Server};SERVER="+server_name+";DATABASE="+database_name)
db_cursor=cnx.cursor()
vi /etc/odbcinst.ini
[PostgreSQL ANSI]
Description = PostgreSQL ODBC driver (ANSI version)
Driver = psqlodbca.so
Setup = libodbcpsqlS.so
Debug = 0
CommLog = 1
UsageCount = 1
[PostgreSQL Unicode]
Description = PostgreSQL ODBC driver (Unicode version)
Driver = psqlodbcw.so
Setup = libodbcpsqlS.so
Debug = 0
CommLog = 1
UsageCount = 1
错误:-
File "build_ver.py", line 11, in <module>
cnx = pyodbc.connect("DRIVER={SQL Server};SERVER="+server_name+";DATABASE="+database_name)
File "/usr/local/lib/python2.7/dist-packages/pypyodbc.py", line 2434, in __init__
File "/usr/local/lib/python2.7/dist-packages/pypyodbc.py", line 2483, in connect
File "/usr/local/lib/python2.7/dist-packages/pypyodbc.py", line 988, in check_success
File "/usr/local/lib/python2.7/dist-packages/pypyodbc.py", line 964, in ctrl_err
pypyodbc.Error: (u'IM002', u'[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified')