pythonms-accessodbcpyodbc

Pyodbc Error - Python to MS Access


I am running on Windows 7, Python 2.7 and Microsoft Access 2013.

When I try running:

import pyodbc
conn_string = '''
DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};
UID=admin;
UserCommitSync=Yes;
Threads=3;
SafeTransactions=0;
PageTimeout=5;
MaxScanRows=8;
MaxBufferSize=2048;
FIL=MS Access;
DriverId=25;
DefaultDir=C:\Users\jseinfeld;
DBQ=C:\Users\jseinfeld\Desktop\Databasetest1.accdb;
'''
connection = pyodbc.connect(conn_string)

I receive the following error message:

Error: ('HY000', "[HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x29dc Thread 0x113c DBC 0x8a3ed48    

Jet'. (63) (SQLDriverConnect); [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x29dc Thread 0x113c DBC 0x8a3ed48

Jet'. (63); [HY000] [Microsoft][ODBC Microsoft Access Driver] Not a valid file name. (-1044); [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x29dc Thread 0x113c DBC 0x8a3ed48 

Jet'. (63); [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x29dc Thread 0x113c DBC 0x8a3ed48

Jet'. (63); [HY000] [Microsoft][ODBC Microsoft Access Driver] Not a valid file name. (-1044)")

I realize there are many questions regarding Pyodbc and MS Access. I have already executed the following:

1) Ensured I have 64 bit Python and 64 bit MS Access

2) Given permission to the account access to the HKEY_LOCAL_MACHINE\SOFTWARE\ODBC registry key

https://support.microsoft.com/en-us/kb/295297

Error in opening an Access database in python

"General error Unable to open registry key Temporary (volatile) ..." from Access ODBC

3) Tried to ensure I have a valid connection string https://stackoverflow.com/questions/6469545/python-connecting-to-a-database-with-pyodbc-not-working#=

4) The Access database is not open when I try running this code. I have re-booted my computer and am still receiving this error.

Please let me know if there is any other action I can try.


Solution

  • Start with a simple connection string with only the DRIVER and DBQ attributes and no embedded line breaks ...

    conn_string = r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\Users\jseinfeld\Desktop\Databasetest1.accdb;'
    

    Once you get the simplest connection string working, you can add and test other connection attributes as needed.