I’m trying to connect to a MS access database using the following code:
JavaScript
x
7
1
from PyQt5.QtSql import QSqlDatabase
2
3
db = QSqlDatabase.addDatabase("QODBC")
4
db.setDatabaseName(
5
"DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=D:\database.accdb")
6
if db.open(): print("opened")
7
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.