“ [ODBC Microsoft Access驱动程序]不是有效的文件名。
我是Python和PyodBC的新手。我尝试将访问数据库与以下代码连接,但请继续获取“ [ODBC Microsoft Access驱动程序]不是有效的文件名”错误。
我尝试安装访问数据库引擎,并在数据库目录中使用两个后斜线而不是一个。
当我查看ODBC数据源时,Microsoft Access驱动程序( *.MDB, *.ACCDB)似乎已安装。我在另一个没有运气的系统上尝试了它。
import pyodbc
conn_str = (
r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};'
r'DBQ="C:\Users\PC\Desktop\testdatabase.accdb";'
)
cnxn = pyodbc.connect(conn_str)
crsr = cnxn.cursor()
for physical_properties in crsr.tables(tableType='TABLE'):
print(physical_properties.table_name)
任何帮助都将不胜感激。提前致谢。
I am new to Python and Pyodbc. I try to connect an access database with below code but keep getting "[ODBC Microsoft Access Driver] Not a valid file name" error.
I tried to install Access Database Engine and using two backslashes instead of one in the database directory.
When I look at the ODBC data sources Microsoft Access Driver (*.mdb, *.accdb) seems to be installed. I tried It on another system with no luck.
import pyodbc
conn_str = (
r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};'
r'DBQ="C:\Users\PC\Desktop\testdatabase.accdb";'
)
cnxn = pyodbc.connect(conn_str)
crsr = cnxn.cursor()
for physical_properties in crsr.tables(tableType='TABLE'):
print(physical_properties.table_name)
Any help would be much appreciated. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
FileSpec不能周围有报价。这失败了,
但这有效
The filespec cannot have quotes around it. This fails
but this works