0

For some reason I have have a hard time with my access driver here. I use the driver to connect to my access database. The error I am getting is:

2022-01-24 08:46:07 AM | ERROR    | Zero Dollar Fee Aging Report  | Error reading database.
2022-01-24 08:46:07 AM | ERROR    | Zero Dollar Fee Aging Report  | (pyodbc.Error) ('HY000', "[HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x3cdc Thread 0x4a3c DBC 0xe8b4534                                                              Jet'. (63) (SQLDriverConnect); [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x3cdc Thread 0x4a3c DBC 0xe8b4534                                                              Jet'. (63); [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use '(unknown)'; file already in use. (-1024)")
(Background on this error at: http://sqlalche.me/e/13/dbapi)

Here is the block code I'm using:

def access_engine(db_path):
"""A function to generate a sqlalchemy engine for an Access database. This
function requires the user to have a compatible Access driver installed
(usually a 32-bit driver with a 32-bit Python installation).
Args:
    db_path (str): The relative or absolute path to the database, ending in
        *.mdb or *.accdb.
Returns:
    sqlalchemy.engine.base.Engine: An engine to connect to the database.
"""
# TODO: Add a check for driver installation
connection_string = str(
    r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};'
    r'DBQ=%s' % db_path)
connection_url = "access+pyodbc:///?odbc_connect={}".format(
    urllib.parse.quote_plus(connection_string))
return _create_engine(connection_url)

def read_database(logger, db_path, table):
logger = dmttools.util.DefaultLogger(logger)
logger.info('Reading existing database...')

sq = "SELECT * FROM `{}`"
    
try:
    engine = dmttools.database.access_engine(db_path)
    df = pd.read_sql_query(sq.format(table), engine)
    logger.info('Read.')
    return df
except Exception as e:
    logger.error('Error reading database.')
    logger.error(e)
    raise e
finally:
    engine.dispose()

access_zeroDollar = read_database('Zero Dollar Fee Aging Report', dmttools.paths.payments_db, 'Site Visit Fees-Zero Amount')

Is anyone else encountering this?

Mike Mann
  • 380
  • 2
  • 12
  • Likely a combination of the two above when this started occurring recently. The error indicates the database is locked, a recent update caused Access databases to get locked when they shouldn't be, but that's fixed in the newest version. – Erik A Jan 24 '22 at 17:16
  • @ErikA when you say it's fixed in the newest version are you referring to the driver or the Microsoft package? I wasn't able to find a new driver and after the recent update is when I have been seeing the error – Mike Mann Jan 24 '22 at 17:27
  • They unfortunately haven't released a database engine update, but you can download the updated runtime: https://support.microsoft.com/en-us/office/download-and-install-microsoft-365-access-runtime-185c5a32-8ba9-491e-ac76-91cbe3ea09c9. Make sure to force it to update: https://support.microsoft.com/en-us/office/install-office-updates-2ab296f3-7f03-43a2-8e50-46de917611c5 – Erik A Jan 24 '22 at 17:31

0 Answers0