Connection error to Access database

孤人 提交于 2019-12-02 02:35:36

The driver name you specified...

DRIVER={Microsoft Access Driver (*.accdb)}

...is incorrect. There is no ODBC driver with that name. 32-bit applications that want to open an older .mdb database file can use

Driver={Microsoft Access Driver (*.mdb)}

To open an .mdb file from a 64-bit application, or to open an .accdb file from any application, you need to use

Driver={Microsoft Access Driver (*.mdb, *.accdb)}

Louis

It looks like you do not have connected to the DB. Maybe you should begin with a smaller program just to connect. Samples in other questions : Using Microsoft Access SQL operators in Python ODBC

This might help.

import pyodbc

# Connect to your access database file

DBfile = 'Filename.mdb'  # Let your file name <Filename> and access extension .mdb
conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ='+DBfile)  #    user/password can be used
cur = conn.cursor()

# Create new table in database

cur.execute ('CREATE TABLE CLIENTS (ID INTEGER, COMPANY STRING)')
conn.commit()

cur.close()
conn.close()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!