简体   繁体   中英

Connection strings using pyodbc module not working with Enthought Python Distribution

Background

I have been using a 64bit version of Python 2.7.3. I wanted to learn the matplotlib and numpy libraries so I ended up installing the Enthought Python Distribution for Windows and I also installed ipython to go along with it as well. Now, all of a sudden connection strings that previously worked are no longer working with the pyodbc library in this distribution of Python and I do not have the slightest clue why.

Example

The following code worked perfectly fine before:

import pyodbc
dbFile = r'D:\Dropbox\School\Senior_Project\Database\HarmonicProfileDatabase_be.accdb'
cnxn = pyodbc.connect(r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ='+dbFile)

But now returns the following error:

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

These kind of things make learning programming so frustrating but I am way too close to coming up with a solution for a project that I have been working on to give up now.

The problem was that the version of Python (and also pyodbc) that I was using was 32-bit. However, I managed to get myself a 64-bit version of office. Both of them need to be 32-bit (or both 64-bit) in order for this to work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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