0

I am trying to access a .mdb file which located on my system. 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. using Ubuntu 12.04 Can any one sya me what is wrong here

ifixthat
  • 6,137
  • 5
  • 25
  • 42

1 Answers1

2

I get this info from 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. Common reasons for this error are:

The DSN "dsn_does_not_exist" does not exist in your USER or SYSTEM ini files.

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.

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).

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.

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. Run ldd on the driver shared object named by Driver= in the odbcinst.ini file and see what dependent shared objects cannot be found. 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.

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
pavelpy
  • 21
  • 5