如何使用Python的DB API列出数据库表?
如果做不到,还有另外一种方法吗?
谢谢
我正在尝试使用 访问 Access 数据库 ( .mdb
) pyodbc
。
我可以很好地连接到它\xe2\x80\x94
\n\nconnection = pyodbc.connect(driver=\'{Microsoft Access Driver (*.mdb)}\', dbp=path, pwd=password)\n
Run Code Online (Sandbox Code Playgroud)\n\n但我无法查询MSysObjects
以获取其表的列表\xe2\x80\x94
cursor = connection.cursor()\ncursor.execute(\'select * from MSysObjects where Type=1 and Flags=0\')\n
Run Code Online (Sandbox Code Playgroud)\n\n它给了我\xe2\x80\x94
\n\nRecord(s) cannot be read; no read permission on \'MSysObjects\'. (-1907) (SQLExecDirectW)\n
Run Code Online (Sandbox Code Playgroud)\n\n浏览了一下,好像是因为数据库被“保护”了。
\n\n我无法运行 Access 来更改它。有什么地方可以以编程方式解决这个问题吗?我需要知道数据库用户或类似的信息吗?
\n\n我在 Visual Basic \xe2\x80\x94 中看到了一种解决方法,有没有办法可以在 Python 中进行调整?我想我需要一个不同的库(OLEDB)。
\n\n谢谢!
\n