I’m trying to connect to a MS access database using the following code:
from PyQt5.QtSql import QSqlDatabase db = QSqlDatabase.addDatabase("QODBC") db.setDatabaseName( "DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=D:\database.accdb") if db.open(): print("opened")
I have office 2019 installed. I cannot figure out what is wrong in the connection string or the driver.
Advertisement
Answer
I figured out that this problem happened because I have a 64-bit of python and a 32-bit of access database engine driver.
After installing the 64-bit access database engine driver, I managed to get it work.