Microsoft Access数据库引擎找不到输入表或查询

2024-09-30 01:34:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试与Microsoft Office建立连接并运行查询,但显示错误

这是我的密码:

import pyodbc

conn = pyodbc.connect(r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=E:\Python\Database\att2000.accdb;')
cursor = conn.cursor()
cursor.execute("SELECT CHECKINOUT FROM att2000 Where CHECKTYPE = O")

for row in cursor.fetchall():
    print (row)

以下是错误:

Error is occurring while executing the query
----> 5 cursor.execute("SELECT CHECKINOUT FROM att2000 Where CHECKTYPE = O")
      6 
      7 for row in cursor.fetchall():

ProgrammingError: ('42S02', "[42S02] [Microsoft][ODBC Microsoft Access Driver] The Microsoft Access database engine cannot find the input table or query 'att2000'. Make sure it exists and that its name is spelled correctly. (-1305) (SQLExecDirectW)")

Tags: fromexecuteaccessdriver错误connwhereselect

热门问题