How can I access my Microsoft Access 2010 database (accdb) with pyodbc? Before, I used an mdb Database, which worked fine with the connection string being:
ODBC_CONN_STR = 'DRIVER={Microsoft Access Driver (*.mdb)};DBQ=%s;' % ACCESS_DATABASE_FILE
Now I use:
import pyodbc
ACCESS_DATABASE_FILE = "PSA_TEST.accdb"
ODBC_CONN_STR = 'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=%s;' % ACCESS_DATABASE_FILE
conn = pyodbc.connect(ODBC_CONN_STR)
The error I get is: pyodbc.Error: ('HY000', '[HY000] [Microsoft][ODBC-Treiber für Microsoft Access] Kein zulässiger Dateiname. (-1044) (SQLDriverConnect)')
Which translates to "the filename is not acceptable". I found a related question, but the answer does not work for me (Connecting to MS Access 2007 (.accdb) database using pyodbc). I use 32 bit python according to the output of:
python -c 'import struct; print struct.calcsize("P") * 8'
and MS Access 32 bit.
[EDIT]
- Just in case, I check with os.path.isfile(ACCESS_DATABASE_FILE) that the file actually exists
- the file can be opened with Access
- opening the previous mdb file with the new connection string gives the same error message, which afaik is not the expected behavior