0

I am using pyodbc to access an MSAccess DB and getting the below error:

('HY000', "[HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x43e0 Thread 0x3334 DBC 0xc8f892c).

I know this is related to access rights but couldn't find an answer to resolve (tried to copy the file to another folder, etc.). What puzzles me is that if I create a new DB in the same folder it works (checked access permissions through right click on the DB file and seems to be the same). The only other thing I could think of is that it's a split db (i.e. back end tables in one file and queries/forms in another - but my code tries to access the back end where the tables are). Any ideas?

import pyodbc
import pandas as pd

db_driver = '{Microsoft Access Driver (*.mdb, *.accdb)}'
db_path = 'C:\\Users\Kevin\\Desktop\\Watercolourhoarder_v8_backend.accdb'
conn_str = (rf'DRIVER={db_driver};'
            rf'DBQ={db_path};'r'Mode=Read;')

conn = pyodbc.connect(conn_str)

df = pd.read_sql(sql="select * from tbl_clients", con=conn)
print(df)

conn.close()
Kevin
  • 51
  • 1
  • 6
  • Usually, this is an indication that something's up with the database. Try opening it in Access and running a compact and repair (and of course, verify that the path is correct) – Erik A Dec 08 '22 at 09:56

0 Answers0