Python Connection Error to MS Access Database when MS Access is currently opened

Viewed 32

Code:

import pyodbc

def select_try(file_path, QR_MLST_TABLE_LST):

    try:
        con_string = r"DRIVER={{Microsoft Access Driver (*.mdb, *.accdb)}};DBQ={};".format(file_path)
        conn = pyodbc.connect(con_string)

        cur = conn.cursor()
        cur.execute(f'Select * From {QR_MLST_TABLE_LST}')

        return cur.fetchall()

    except pyodbc.Error as e:
        print("Error in Connection", e)

Error:

It is running without any problem in Pycharm if MS Access is closed. But when MS Access is currently opened, it gives this error: FYI, MS Access is on Production Mode. I think it has something to do with that?

ERROR: [HY000] [Microsoft][ODBC Microsoft Access Driver] The database has been placed in a state by an unknown user that prevents it from being opened or locked. (-3810)')

0 Answers
Related