Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

32 bit pyodbc reading 64 bit access (accdb)

I have python 2.7 32 bit running on a Windows 8.1 64 bit machine.

I have Access 2013 and a .accdb file that I'm trying to access from python and pyodbc.

I can create a 64 bit DSN in the 64 bit ODBC manager. However, when I try to connect to it from python, I get the error:

Error: (u'IM002', u'[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified')

Presumably, python is only looking for 32-bit DSNs and doesn't find the 64-bit one that I've created.

When I try to create a 32-bit DSN within the 32-bit ODBC manager, there is no driver for a accdb file (just .mdb).

I think I need a 32 bit ODBC driver for Access 2013 files (.accdb), but haven't been able to find one.

Is it possible to do what I'm trying to do? -- 32bit python access a Access 2013 .accdb file?

like image 515
EpicAdv Avatar asked Dec 02 '22 20:12

EpicAdv


1 Answers

32 bit applications including Python can work only with 32 bit ODBC drivers.

64 bit applications including Python can work only with 64 bit ODBC drivers.

If you have:

  • 32 bit Python with pyodbc module
  • 64 bit MS Access ODBC driver

Then you must change something:

  1. You can install 64 bit version of Python (I use Active Python which has odbc module), then you can use 64 bit version of pyodbc module (I see it for Python 2.6, 2.7 and 3.3)
  2. You can install 32 bit version od MS Access driver

Using pyodbc.dataSources() you can list ODBC sources:

sources = pyodbc.dataSources()
dsns = list(sources.keys())
dsns.sort()
sl = []
for dsn in dsns:
    sl.append('%s [%s]' % (dsn, sources[dsn]))
print('\n'.join(sl))

If you use ActiveState Python then you can list them using odbc module as in my recipe: http://code.activestate.com/recipes/578782-printing-list-of-odbc-data-sources/?in=user-186902

like image 186
Michał Niklas Avatar answered Dec 05 '22 09:12

Michał Niklas