NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:access.pyodbc

9.3k views Asked by At

I want to import a dataframe into a access database but I got an error NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:access.pyodbc

from sqlalchemy import create_engine
import urllib
import pyodbc

conec = (r"Driver={Microsoft Access Driver (*.mdb, *.accdb)};"
         r"DBQ=C:\Users\redim\Desktop\18_marzo\Libr2.accdb"
        )
    
con = f"access+pyodbc:///?odbc_connect={urllib.parse.quote_plus(conec)}"
acc_engine = create_engine(con)
df.to_sql('hola', acc_engine)
1

There are 1 answers

0
Peej1226 On

For some reason this only works in Jupyter notebooks, not in PyCharm which I was having the same problems for quite some time in both until I upgraded SQLalchemy

I use conda install with most of my libraries:

conda update sqlalchemy

But if you are using pip, then below is command:

pip install --upgrade sqlalchemy

I went from sqlalchemy 1.3.7 to 1.4.39 and the error went away, at least in Jupyter Notebooks anyways.