How to connect MS Access to Python using pyodbc

后端 未结 2 985
生来不讨喜
生来不讨喜 2021-02-08 00:51

I\'m having trouble connecting a database in access with pyodbc. I\'ve seen other example codes that appear near identical to mine that work:

import pyodbc 
cnxn         


        
相关标签:
2条回答
  • 2021-02-08 01:02

    I am using Win10 and Office 365, my problem resolved with installing Microsoft Access Database Engine 2016 Redistributable

    Microsoft Access Database Engine 2016 Redistributable

    0 讨论(0)
  • 2021-02-08 01:19

    Since you are using the 32-bit versions of both Microsoft Office and Python you should be good to go once you have the right connection string. It should look like this:

    connStr = (
        r"DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};"
        r"DBQ=C:\full\path\to\your\PYODBC.accdb;"
        )
    cnxn = pyodbc.connect(connStr)
    
    0 讨论(0)
提交回复
热议问题