I am trying to connect to MS Access using sql alchemy. My access is 64 bit. I have tried with both 32-bit python and 64-bit python. The results are the same.
It works using pyodbc:
import pyodbc
from sqlalchemy import create_engine
class MSAccessConnector:
def __init__(self, **kwargs):
self.kwargs = kwargs
def test_connection(self):
try:
conn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C://Users//Gautam Sardana//Documents//gautam.accdb;')
cursor = conn.cursor()
return cursor
except Exception as e:
print(e)
pass
MSAccessConnector().test_connection()
But fails with sqlalchemy:
import pyodbc
from sqlalchemy import create_engine
class MSAccessConnector:
def __init__(self, **kwargs):
self.kwargs = kwargs
def test_connection(self):
try:
engine = create_engine(r'access:///C:/Users/Gautam Sardana/Documents/gautam.accdb')
return engine
except Exception as e:
print(e)
pass
def connect(self):
pass
MSAccessConnector().test_connection()
I get the error:
Can't load plugin: sqlalchemy.dialects:access