简体   繁体   English

pyodbc:ubuntu上的.mdb连接错误

[英]pyodbc: .mdb connection error on ubuntu

I am trying to access a .mdb file which located on my system. 我正在尝试访问位于我的系统上的.mdb文件。 My Code look slike this : 我的代码看起来像这样:

import csv
import pyodbc

MDB = '/home/filebug/client/my.mdb'
DRV = '{Microsoft Access Driver (*.mdb)}'
PWD = 'mypassword'

conn = pyodbc.connect('DRIVER=%s;DBQ=%s;PWD=%s' % (DRV,MDB,PWD))
print conn
curs = conn.cursor()

SQL = 'SELECT * FROM InOutTable;' # insert your query here
curs.execute(SQL)

rows = curs.fetchall()

curs.close()
conn.close()

But I am facing following Error : 但我面临以下错误:

Traceback (most recent call last):
  File "mdb.py", line 8, in <module>
    conn = pyodbc.connect('DRIVER=%s;DBQ=%s;PWD=%s' % (DRV,MDB,PWD))
pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)')

I have pyodbc-3.0.6-py2.7-linux-i686.egg installed on my system. 我在我的系统上安装了pyodbc-3.0.6-py2.7-linux-i686.egg using Ubuntu 12.04 Can any one sya me what is wrong here 使用Ubuntu 12.04任何人都可以告诉我这里有什么问题

I get this info from http://www.easysoft.com/developer/interfaces/odbc/linux.html 我从http://www.easysoft.com/developer/interfaces/odbc/linux.html获取此信息

In this case unixODBC could not locate the DSN "dsn_does_not_exist" and hence could not load the ODBC driver. 在这种情况下,unixODBC无法找到DSN“dsn_does_not_exist”,因此无法加载ODBC驱动程序。 Common reasons for this error are: 此错误的常见原因是:

The DSN "dsn_does_not_exist" does not exist in your USER or SYSTEM ini files. 您的USER或SYSTEM ini文件中不存在DSN“dsn_does_not_exist”。

The DSN "dsn_does_not_exist" does exist in a defined ini file but you have omitted the "Driver=xxx" attribute telling the unixODBC driver manager which ODBC driver to load. DSN“dsn_does_not_exist”确实存在于已定义的ini文件中,但您省略了“Driver = xxx”属性,告知unixODBC驱动程序管理器要加载哪个ODBC驱动程序。

The "Driver=/path_to_driver" in the odbcinst.ini file points to an invalid path, to a path to an executable where part of the path is not readable/searchable or to a file that is not loadable (executable). odbcinst.ini文件中的“Driver = / path_to_driver”指向无效路径,指向可执行文件的路径,其中部分路径不可读/可搜索,或指向不可加载(可执行)的文件。

The Driver=xxx entry points to a shared object which does not export the necessary ODBC API functions (you can test this with dltest included with unixODBC. Driver = xxx条目指向一个共享对象,该对象不导出必要的ODBC API函数(您可以使用unixODBC附带的dltest进行测试)。

The ODBC driver defined by DRIVER=xxx in the odbcinst.ini file depends on other shared objects which are not on your dynamic linker search path. odbcinst.ini文件中由DRIVER = xxx定义的ODBC驱动程序依赖于动态链接器搜索路径上不存在的其他共享对象。 Run ldd on the driver shared object named by Driver= in the odbcinst.ini file and see what dependent shared objects cannot be found. 在odbcinst.ini文件中的Driver =命名的驱动程序共享对象上运行ldd,查看无法找到哪些依赖共享对象。 If some cannot be found than you need to defined your LD_LIBRARY_PATH environment variable to define the paths to any dependent shared objects or add these paths to /etc/ld.so.conf and rerun ldconfig. 如果找不到某些内容,则需要定义LD_LIBRARY_PATH环境变量以定义任何相关共享对象的路径,或将这些路径添加到/etc/ld.so.conf并重新运行ldconfig。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM